[Tutor] create 1000 000 variables

Kent Johnson kent37 at tds.net
Sat Jul 15 13:24:13 CEST 2006


Fabrizio Milo aka misto wrote:
> Hi!
> I don't know why you want to do that but actually it is possibble.
>
>   
>>>> for i in xrange(10000):
>>>>         
> ...    exec( 'var_%s = "var_%s"' %(i,i), locals() )
>
>   
>>>> var_100
>>>>         
> 'var_100'

It is possible but it's unlikely that it is the best solution to 
whatever problem the OP is trying to solve. Any reference to the 
variables created will be similarly roundabout.

Kent



More information about the Tutor mailing list