exec example - I don't understand

kepes.krisztian at peto.hu kepes.krisztian at peto.hu
Tue Jun 29 07:11:37 EDT 2004


Hi !

In 


  Unifying types and classes in Python 2.2

article I see that:

>>> print a                         # show the result
{1: 3.25, 2: 200}
>>>

We can also use the new type in contexts where classic only allows 
"real" dictionaries, such as the locals/globals dictionaries for the 
exec statement or the built-in function eval():

>>> print a.keys()
[1, 2]
>>> exec "x = 3; print x" in a
3

But I dont' understand that:
	exec "x = 3; print x" in a

So what this code do ?
Why we need "in a" ?

This get same result !

Thanx for help:
 FT
   





More information about the Python-list mailing list