create global variables?

Fredrik Lundh fredrik at pythonware.com
Mon Oct 30 12:52:40 EST 2006


Wojciech Muła wrote:

>> is there a simple way of creating global variables within a function?
> 
> def foo(name):
> 	globals()[name] = "xxx"
> 	globals()[name + 'aa'] = "yyy"
> 	globals()[name + 'ab'] = "zzz"

that kind of coding is punishable by law in some jurisdictions.

</F>




More information about the Python-list mailing list