Message130628
| 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. |
|