classification
Title: add shorthand global and nonlocal statements
Type: feature request Stage: patch review
Components: Interpreter Core Versions: Python 3.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: amaury.forgeotdarc, benjamin.peterson, georg.brandl, jhylton (4)
Priority: normal Keywords needs review, patch

Created on 2008-10-24 22:32 by benjamin.peterson, last changed 2009-11-04 22:46 by pitrou.

Files
File name Uploaded Description Edit Remove
global_nonlocal_shorthand.patch benjamin.peterson, 2008-10-24 23:24
global_nonlocal_shorthand2.patch benjamin.peterson, 2008-12-06 18:28
Messages (5)
msg75193 - (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-10-24 22:32
PEP 3104 says that the nonlocal and global statements should allow a
shorthand. ("global x; x = 3" == "global x = 3") This patch implements that.
msg77089 - (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-12-06 01:22
Please review.
msg77134 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) Date: 2008-12-06 15:30
- the add_ast_fields() function seems to be added by this patch, but it 
is already in svn.

- Are 1-tuple supported?

    t = [1]
    global a, = t
msg77159 - (view) Author: Benjamin Peterson (benjamin.peterson) Date: 2008-12-06 18:28
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
new flag* to the Global and Nonlocal AST objects that indicates whether
the value needs to be unpacked or not.

* The flag is an int. The bool AST type was removed in py3k.
msg88874 - (view) Author: Georg Brandl (georg.brandl) Date: 2009-06-04 10:08
Postponed to 3.2.
History
Date User Action Args
2009-11-04 22:46:02pitrousetpriority: critical -> normal
2009-06-04 10:08:18georg.brandlsetnosy: + georg.brandl

messages: + msg88874
versions: + Python 3.2, - Python 3.1
2009-03-31 16:16:43jhyltonsetnosy: + jhylton
2008-12-08 01:10:52benjamin.petersonsetpriority: high -> critical
2008-12-06 18:28:37benjamin.petersonsetfiles: + global_nonlocal_shorthand2.patch
messages: + msg77159
2008-12-06 15:30:49amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg77134
2008-12-06 01:22:54benjamin.petersonsetkeywords: + needs review
type: feature request
messages: + msg77089
stage: patch review
2008-10-24 23:24:46benjamin.petersonsetfiles: + global_nonlocal_shorthand.patch
2008-10-24 22:47:09benjamin.petersonsetfiles: - global_nonlocal_short_assign.patch
2008-10-24 22:32:14benjamin.petersoncreate