[Tutor] The exec command and namespaces
Jaidev Deshpande
deshpande.jaidev at gmail.com
Fri Aug 10 22:44:49 CEST 2012
Hi,
Supposed I have a string containing a python script and I exec that script.
Is there a way to keep track of the variables that this exec() command creates?
Say,
>>> s = 'for i in range(10):\n\tprint i\n\n'
>>> exec(s)
0
1
2
3
4
5
6
7
8
9
Is there a way to ascertain that the variable 'i' was created through
the exec function? I'm looking for a way to identify all python
variables that a given exec call creates.
Thanks
More information about the Tutor
mailing list