[docs] [issue11418] Method's global scope is module containing function definition, not class.

R. David Murray report at bugs.python.org
Fri Mar 11 23:06:16 CET 2011


R. David Murray <rdmurray at bitdance.com> added the comment:

If you do a "def foo" in module bar.py, and have a class FooFoo in bar.py, and do:

FooFoo.myfoo = foo

and foo refers to an unbound variable, that variable will be looked up in bar.py's global name space.

If instead the 'def foo' is in a module parrot.py, and bar.py does:

from parrot import foo
FooFoo.myfoo = foo

and foo contains an unbound variable, that variable will be looked up in *parrots* global name space.

So, yes, this is a doc bug of a sort :)  It would be technically correct to change it to "The global scope associated with a method is the module containing the method's function definition", but that is not suitable for the tutorial.  In fact, the discussion of this quirk probably doesn't belong in the tutorial; unless, perhaps, in a footnote.

----------
nosy: +r.david.murray

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue11418>
_______________________________________


More information about the docs mailing list