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.

Author serprex
Recipients serprex
Date 2010-06-11.20:26:37
SpamBayes Score 0.07983468
Marked as misclassified No
Message-id <1276288000.72.0.276261442461.issue8977@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2010-06-11 20:26:43serprexsetrecipients: + serprex
2010-06-11 20:26:40serprexsetmessageid: <1276288000.72.0.276261442461.issue8977@psf.upfronthosting.co.za>
2010-06-11 20:26:39serprexlinkissue8977 messages
2010-06-11 20:26:39serprexcreate