This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients docs@python, eric.araujo, methane, r.david.murray, santoso.wijaya
Date 2011-03-11.22:06:16
SpamBayes Score 1.1858908e-05
Marked as misclassified No
Message-id <1299881176.84.0.687230377893.issue11418@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2011-03-11 22:06:16r.david.murraysetrecipients: + r.david.murray, eric.araujo, methane, santoso.wijaya, docs@python
2011-03-11 22:06:16r.david.murraysetmessageid: <1299881176.84.0.687230377893.issue11418@psf.upfronthosting.co.za>
2011-03-11 22:06:16r.david.murraylinkissue11418 messages
2011-03-11 22:06:16r.david.murraycreate