Values and objects
Rotwang
sg552 at hotmail.co.uk
Sun May 11 09:46:10 EDT 2014
On 11/05/2014 04:11, Steven D'Aprano wrote:
> [...]
>
> And try running
> this function in both 2.7 and 3.3 and see if you can explain the
> difference:
>
> def test():
> if False: x = None
> exec("x = 1")
> return x
I must confess to being baffled by what happens in 3.3 with this
example. Neither locals() nor globals() has x = 1 immediately before the
return statement, so what is exec("x = 1") actually doing?
More information about the Python-list
mailing list