dynamically creating variables

James Stroud jstroud at ucla.edu
Fri Mar 3 17:58:16 EST 2006


Crutcher wrote:
>>Is it possible to do something like that?
> 
> 
> No, you can't change the binding of variables in your calling space.
> 

Unless your calling space is global

py> def doit():
...   globals()['wilma'] = 'pebbles'
...
py> doit()
py> wilma
'pebbles'

But that would be crazy.



More information about the Python-list mailing list