-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add shorthand global and nonlocal statements #48449
Comments
PEP-3104 says that the nonlocal and global statements should allow a |
Please review. |
t = [1]
global a, = t |
I think I may have been merging add_ast_fields when I wrote the patch. Here's a new patch that handles "global x, = (5,)". To do it, I added a
|
Postponed to 3.2. |
Bumping priority so this doesn't get forgotten before 3.2; it seems important because it fixes noncompliance with a PEP. |
"High" is not high enough :) |
Is deferred blocker a higher priority? Jeremy On Tue, Feb 23, 2010 at 4:37 PM, Georg Brandl <report@bugs.python.org> wrote:
|
I interpret the "Priority" list view contents to be sorted by priority, so "deferred blocker" is the second-highest. |
On Sat, Dec 6, 2008 at 1:28 PM, Benjamin Peterson
You shouldn't need to do this. The unpack is implied if the number of Jeremy
|
I also notice that the Grammar in the PEP is more complicated: The Grammar in the patch is: It appears that the PEP is trying to support: nonlocal x = y = z = 1 If we're going to support the PEP as written, I think we need to This approach makes the compiler code very simple. We use exactly the It also means that the AST will change in a non-backwards compatible Jeremy On Tue, Feb 23, 2010 at 6:41 PM, Jeremy Hylton <jeremy@alum.mit.edu> wrote:
|
It also tries to support augmented assignment; however I'm not sure what the semantics of that should be. Further, there is an ambiguity if too much freedom is allowed: what about global x = 1, y Is it declaring a global "x" and assigning a tuple, or declaring a global "x" and a global "y"?
I would not support List or Tuple as targets. Same basic problem as I see two possibilities for the actual syntax:
In both cases, I would keep it simple and not allow multiple targets or |
I guess there's some question about whether the syntax in the PEP was I'd argue that the intent of the PEP is pretty clear. You can take Jeremy On Wed, Feb 24, 2010 at 4:20 AM, Georg Brandl <report@bugs.python.org> wrote:
|
I do think a brief discussion after the moratorium is over would be good. |
I'm not sure as to the status of this. Could it go back to (say) 3.3, is it still a candidate for 3.2(.x), or what? |
2010/7/18 Mark Lawrence <report@bugs.python.org>:
It can't do anything until 3.3. |
We could also just decide we don't need it :) If we do (I haven't read the PEP) does a statement with an assignment make the variable global in that scope, or does it only affect the global variable for the duration of the assignment, and otherwise the variable remains local in the scope? (I don't know which to guess, and the ambiguity is disturbing. I like the current clarity even if it is more typing.) |
+1 on the feature as described in the PEP. |
Bumping version to 3.4. I'll send a note to python-dev about this issue. |
Closing and rejecting based on said discussion. http://mail.python.org/pipermail/python-dev/2013-June/127143.html |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: