[issue4109] Wrong UnboundLocalError with += operator

2008-10-12 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: Inplace operators ("+=", "-=" etc) are assignments since in the case of immutable types like str code += "some string" is equivalent to code = code + "some string" -- resolution: -> invalid status: open -> closed _

[issue4109] Wrong UnboundLocalError with += operator

2008-10-12 Thread Benjamin Peterson
Benjamin Peterson <[EMAIL PROTECTED]> added the comment: Is code a global variable? -- nosy: +benjamin.peterson ___ Python tracker <[EMAIL PROTECTED]> ___ _

[issue4109] Wrong UnboundLocalError with += operator

2008-10-12 Thread Eric Atienza
New submission from Eric Atienza <[EMAIL PROTECTED]>: the following code : def test(): code='' def sub(n): for i in range(n): code+=str(i) sub(5) sub(10) return code >>> test() Traceback (most recent call last): File "", line 1, in File "", line 6, i