exec "global" problem
piet at cs.uu.nl
piet at cs.uu.nl
Thu Jun 28 06:41:44 EDT 2001
>>>>> Michaell Taylor <nytaylor at bestweb.net> (MT) writes:
MT> I have seen lots of discussion of the problem of executing the following code:
MT> global sub
MT> sub=['sub1', 'sub2', ...'sub600']
MT> def make():
MT> for X in range(1,600):
MT> exec "global sub%s" % (X)
MT> exec "sub%s={}" % (X)
MT> other stuff
If you just want to create these 600 variables do the following:
def make():
for X in range(1,600):
exec "global sub%s;sub%s={}" % (X,X)
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP]
Private email: P.van.Oostrum at hccnet.nl
More information about the Python-list
mailing list