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 2012年04月11日 04:46 by ncoghlan, last changed 2022年04月11日 14:57 by admin.
| Messages (4) | |||
|---|---|---|---|
| msg158005 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2012年04月11日 04:46 | |
The language spec currently includes the following paragraph [1]: Names listed in a global statement must not be defined as formal parameters or in a for loop control target, class definition, function definition, or import statement. While the first restriction is real (and enforced by CPython), since formal parameters are explicitly defined as local variables, there's no obvious rationale for the last 4 restrictions (and CPython doesn't enforce any of them). The proposal is that the paragraph be simplified to: Names listed in a global statement must not also be defined as formal function parameters. Attempting to do so raises SyntaxError. The current (incorrect!) CPython implementation detail note will be removed. A similar clarification will also be made in the "nonlocal" statement documentation. [1] http://docs.python.org/dev/reference/simple_stmts.html#the-global-statement |
|||
| msg158006 - (view) | Author: Alex Gaynor (alex) * (Python committer) | Date: 2012年04月11日 04:51 | |
This shouldn't be a problem for PyPy, in fact I'm almost positive that we implement this already (since Django has a test that uses this "feature"). If/when the spec is changed please make sure there are tests for all these cases so we *know* it works though. |
|||
| msg158007 - (view) | Author: Alyssa Coghlan (ncoghlan) * (Python committer) | Date: 2012年04月11日 04:52 | |
Thread link: http://mail.python.org/pipermail/python-ideas/2012-April/014783.html |
|||
| msg237252 - (view) | Author: Raymond Hettinger (rhettinger) * (Python committer) | Date: 2015年03月05日 09:29 | |
+1 for the proposed change. It should add there is also an enforced (and obvious) restriction that the variable not have been declared nonlocal. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:29 | admin | set | github: 58749 |
| 2015年03月05日 10:03:11 | ezio.melotti | set | nosy:
+ ezio.melotti stage: needs patch versions: + Python 3.5, - Python 3.3 |
| 2015年03月05日 09:29:58 | rhettinger | set | nosy:
+ rhettinger messages: + msg237252 |
| 2015年03月05日 08:51:06 | fossilet | set | nosy:
+ fossilet |
| 2012年04月13日 17:18:24 | terry.reedy | set | nosy:
+ terry.reedy |
| 2012年04月11日 05:28:54 | cvrebert | set | nosy:
+ cvrebert |
| 2012年04月11日 05:03:36 | eric.araujo | set | nosy:
+ eric.araujo |
| 2012年04月11日 04:52:27 | ncoghlan | set | messages: + msg158007 |
| 2012年04月11日 04:51:52 | alex | set | nosy:
+ alex messages: + msg158006 |
| 2012年04月11日 04:46:30 | ncoghlan | create | |