[issue15621] UnboundLocalError on simple in-place assignment of an inner scope

2012-08-10 Thread R. David Murray
R. David Murray added the comment: In t2, you assign to num. That makes it local. In t1, you don't, so num is picked up from the global scope. -- nosy: +r.david.murray resolution: -> invalid stage: -> committed/rejected status: open -> closed ___

[issue15621] UnboundLocalError on simple in-place assignment of an inner scope

2012-08-10 Thread zipher
New submission from zipher: >>> num = 1 >>> def t1(): print num >>> t1() 1 >>> def t2(): ... num+=1 ... print num >>> t2() UnboundLocalError: local variable 'num' referenced before assignment It seems num is bound in t1, but not t2, even though they are the same scope. Am I missing s