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.
Created on 2011年03月06日 23:28 by methane, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (7) | |||
|---|---|---|---|
| msg130201 - (view) | Author: Inada Naoki (methane) * (Python committer) | Date: 2011年03月06日 23:28 | |
http://docs.python.org/py3k/tutorial/classes.html#random-remarks > Methods may reference global names in the same way as ordinary > functions. The global scope associated with a method is the module > containing the class definition. (The class itself is never used > as a global scope.) Method's function can be defined outside the module containing class definition. And then the method's global scope is module containing method's function definition. |
|||
| msg130619 - (view) | Author: Éric Araujo (eric.araujo) * (Python committer) | Date: 2011年03月11日 21:44 | |
I’m afraid I don’t understand "Method's function". Could you rephrase, or give a commented code example showing the bad behavior? |
|||
| msg130628 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2011年03月11日 22:06 | |
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. |
|||
| msg131389 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2011年03月19日 05:11 | |
"Methods defined within a class may reference..." would make the tutorial correct without introducing the complication of methods defined outside a class, let alone in another module. |
|||
| msg150997 - (view) | Author: Terry J. Reedy (terry.reedy) * (Python committer) | Date: 2012年01月10日 03:11 | |
This paragraph follows a discussion and example of the fact that methods do *not* have to be defined within a class statement. Any objections to changing "The global scope associated with a method is the module containing the class definition. (The class itself is never used as a global scope.)" to "The global scope associated with a method is the module containing its definition. (A class is never used as a global scope.)" ? |
|||
| msg151004 - (view) | Author: Inada Naoki (methane) * (Python committer) | Date: 2012年01月10日 05:45 | |
> Any objections to changing > > "The global scope associated with a method is the module containing the class definition. (The class itself is never used as a global scope.)" > > to > > "The global scope associated with a method is the module containing its definition. (A class is never used as a global scope.)" > > ? +1 |
|||
| msg151085 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2012年01月11日 19:57 | |
New changeset 10a5165103f9 by Terry Jan Reedy in branch '2.7': Minor correction. Closes #11418 http://hg.python.org/cpython/rev/10a5165103f9 New changeset 32ea3675fba2 by Terry Jan Reedy in branch '3.2': Minor correction. #11418 http://hg.python.org/cpython/rev/32ea3675fba2 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:14 | admin | set | github: 55627 |
| 2012年01月11日 19:57:46 | python-dev | set | status: open -> closed nosy: + python-dev messages: + msg151085 resolution: fixed stage: resolved |
| 2012年01月10日 05:45:10 | methane | set | messages: + msg151004 |
| 2012年01月10日 03:11:59 | terry.reedy | set | messages:
+ msg150997 versions: - Python 3.1 |
| 2011年03月19日 05:11:07 | terry.reedy | set | nosy:
+ terry.reedy messages: + msg131389 |
| 2011年03月11日 22:06:16 | r.david.murray | set | nosy:
+ r.david.murray messages: + msg130628 |
| 2011年03月11日 21:44:29 | eric.araujo | set | nosy:
+ eric.araujo messages: + msg130619 versions: - Python 2.6 |
| 2011年03月06日 23:48:39 | santoso.wijaya | set | nosy:
+ santoso.wijaya |
| 2011年03月06日 23:28:34 | methane | set | assignee: docs@python nosy: + docs@python components: + Documentation versions: + Python 2.6, Python 3.1, Python 2.7, Python 3.2, Python 3.3 |
| 2011年03月06日 23:28:20 | methane | create | |