Creating variables from dicts

Rhodri James rhodri at wildebst.demon.co.uk
Wed Feb 24 18:42:47 EST 2010


On Wed, 24 Feb 2010 13:41:08 -0000, Luis M. González <luismgz at gmail.com>  
wrote:

> This is the only way I know to define variables programatically in the
> top-level namespace, without having to do it manually one by one.

We see requests for this a lot, and the response that's frequently missed  
amongst all the technical trickery is "What on earth makes you think that  
defining variables programatically will help?"  Usually the sensible thing  
is to collect such "variables" into a list or dictionary, since that's the  
only way you're going to access them safely without a whole heap more  
technical trickery.

-- 
Rhodri James *-* Wildebeeste Herder to the Masses



More information about the Python-list mailing list