Poor Yorick wrote:
In the following snippet, the loop in the global namespace takes twice as long as the loop in the function namespace. Why?

Locals are known to have no outside interaction, and so are not looked
up by name.  your code could have a thread that did,
....
     global counter
     while True:
         time.sleep(.1)
         counter *= 2
....

For that matter, it could do ... del counter ... and force a NameError
in your second loop.

--Scott David Daniels
scott.dani...@acm.org
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to