Message107581
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 |
|
Date |
User |
Action |
Args |
2010-06-11 20:26:43 | serprex | set | recipients:
+ serprex |
2010-06-11 20:26:40 | serprex | set | messageid: <1276288000.72.0.276261442461.issue8977@psf.upfronthosting.co.za> |
2010-06-11 20:26:39 | serprex | link | issue8977 messages |
2010-06-11 20:26:39 | serprex | create | |
|