New submission from Demur Rumed <junkm...@hotmail.com>:

A=[1,2,3]
def f(x):
    A+=x,

This throws an error. The solution: state "global a". I find it odd that 
augmented assignment should be viewed the same as assignment in descerning 
local variables. This patch repairs such to maintain a as a variable of the 
global namespace

Some might find the following an issue

def f(x):
    if x:
        A+=4,
    else:
        A=[3]
    print("f",x,A)
def g(x):
    if not x:
        A=[3]
    else:
        A+=4,
    print("g",x,A)

In f, A is a global variable. In g, A is a local variable. Thus g(1) throws 
UnboundLocalError while f(1) appends 4 to A

----------
components: Interpreter Core
files: symtable.diff
keywords: patch
messages: 107581
nosy: serprex
priority: normal
severity: normal
status: open
title: Globalize lonely augmented assignment
type: feature request
versions: Python 3.1
Added file: http://bugs.python.org/file17633/symtable.diff

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue8977>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to