hello,
recently i have 'discovered' a little bit 'strange' block of code.
should the 'a' not be encapsulated in the local scope of the 'if-statement' and not accessible from the global name space?
thanks in advance!
recently i have 'discovered' a little bit 'strange' block of code.
a = 5 print(id(a)) if a == 5: a = a + 2 print(a) print(id(a)) print(id(a))the output:
Output:10924160
7
10924224
10924224
it turns out that the interpreter see the ( already ... 'localized'!? ) object 'a' in the global name space also.should the 'a' not be encapsulated in the local scope of the 'if-statement' and not accessible from the global name space?
thanks in advance!