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 2015年03月05日 08:32 by fossilet, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| faq_fix.diff | fossilet, 2015年03月05日 08:32 | review | ||
| faq_fix_1.diff | fossilet, 2015年03月05日 10:39 | review | ||
| Messages (9) | |||
|---|---|---|---|
| msg237248 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2015年03月05日 08:32 | |
In https://docs.python.org/3/faq/programming.html#what-are-the-rules-for-local-and-global-variables-in-python, two sentences of essentially the same meaning exist. I try to remove this redundancy. |
|||
| msg237255 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2015年03月05日 10:18 | |
How about: In Python, variables that are only referenced inside a function are implicitly global. If a variable is assigned a value anywhere within the function's body, it's assumed to be a local unless explicitly declared as global. |
|||
| msg237256 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2015年03月05日 10:39 | |
Updated diff as Raymond's wording. |
|||
| msg237261 - (view) | Author: Ezio Melotti (ezio.melotti) * (Python committer) | Date: 2015年03月05日 11:48 | |
I think the first sentence could be improved, even though it's correct. A superficial reading might give the impression that function variables are implicitly global, or that only the variables inside a function are global, especially if the reader is not familiar with the term "referenced". Swapping the two sentences and talking first about assignment might be enough to make clear that the other sentence is talking about variables that are only read/accessed by the function but not defined/assigned. The paragraph can also be rephrased to say that Python can freely access variables from outer scopes, but that "global" is required to assign a new value to a global variable, and that variables defined inside a function are local. |
|||
| msg237340 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2015年03月06日 10:27 | |
What about changing the first sentence to: In Python, variables that are only referenced but not assigned inside a function are implicitly global.? |
|||
| msg237341 - (view) | Author: Yongzhi Pan (fossilet) * | Date: 2015年03月06日 10:46 | |
Or: In Python, variables inside a function that are only referenced but not assigned are implicitly global.? |
|||
| msg237365 - (view) | Author: Demian Brecht (demian.brecht) * (Python triager) | Date: 2015年03月06日 16:00 | |
Not to throw a wrench into this, but would it perhaps not be worthwhile to refactor this section in order to include nonlocals as well (obviously not for 2.7)? It seems a little odd to me to have this amount of detail without mentioning nonlocal. |
|||
| msg247591 - (view) | Author: Robert Collins (rbcollins) * (Python committer) | Date: 2015年07月29日 18:13 | |
@Demian, I agree that there are more improvements we can make. The current patch addresses the specific issue of this bug, and if you wished to make a new issue with further improvements that would be great. I'm going to apply this patch now though. |
|||
| msg247592 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2015年07月29日 18:20 | |
New changeset 02f3bf3f74aa by Robert Collins in branch '2.7': Issue #23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan. https://hg.python.org/cpython/rev/02f3bf3f74aa New changeset 941b9c27b8c8 by Robert Collins in branch '3.4': Issue #23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan. https://hg.python.org/cpython/rev/941b9c27b8c8 New changeset 93f3ca8fdc39 by Robert Collins in branch '3.5': Issue #23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan. https://hg.python.org/cpython/rev/93f3ca8fdc39 New changeset 7163dd7e9511 by Robert Collins in branch 'default': Issue #23589: Remove duplicate sentence from the FAQ. Patch by Yongzhi Pan. https://hg.python.org/cpython/rev/7163dd7e9511 |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:13 | admin | set | github: 67777 |
| 2015年07月29日 18:21:12 | rbcollins | set | status: open -> closed resolution: fixed stage: commit review -> resolved |
| 2015年07月29日 18:20:39 | python-dev | set | nosy:
+ python-dev messages: + msg247592 |
| 2015年07月29日 18:13:01 | rbcollins | set | nosy:
+ rbcollins messages: + msg247591 |
| 2015年03月06日 16:00:33 | demian.brecht | set | nosy:
+ demian.brecht messages: + msg237365 |
| 2015年03月06日 10:46:43 | fossilet | set | messages: + msg237341 |
| 2015年03月06日 10:27:10 | fossilet | set | messages: + msg237340 |
| 2015年03月05日 11:48:53 | ezio.melotti | set | nosy:
+ r.david.murray messages: + msg237261 |
| 2015年03月05日 10:40:00 | fossilet | set | files:
+ faq_fix_1.diff messages: + msg237256 |
| 2015年03月05日 10:18:13 | rhettinger | set | nosy:
+ rhettinger messages: + msg237255 |
| 2015年03月05日 09:24:12 | ezio.melotti | set | assignee: docs@python -> ezio.melotti stage: commit review nosy: + ezio.melotti versions: + Python 2.7, - Python 3.2, Python 3.3 |
| 2015年03月05日 08:32:38 | fossilet | create | |