break in a module

Ian Kelly ian.g.kelly at gmail.com
Thu Jun 16 21:58:35 EDT 2011


On Thu, Jun 16, 2011 at 7:21 PM, Erik Max Francis <max at alcyone.com> wrote:
>> This would, if I understand imports correctly, have ham() operate in
>> one namespace and spam() in another. Depending on what's being done,
>> that could be quite harmless, or it could be annoying (no sharing
>> module-level constants, etc).
>
> No, he's using `from ... import *`.  It dumps it all in the same namespace
> (which is usually why it's frowned upon, but in his example it's kind of the
> point).

The functions are defined in two separate global namespaces, though.
That means that the actual bindings visible to ham() are different
from the globals visible to spam().  Constants should be fine, but if
ham() modifies a global, then spam() won't see the change, and
vice-versa.

> Neither makes sense.  `break` exits out of looping structures, which the
> top-level code of a module most certainly is not.

Why does that matter?  It seems a bit like arguing that the `in`
keyword can't be used for membership testing, because it's already in
use in the for-loop syntax.  It wouldn't be the first time Python has
reused a keyword.



More information about the Python-list mailing list