printing variables

MonkeeSage MonkeeSage at gmail.com
Fri Oct 6 00:56:04 EDT 2006


s99999999s2003 at yahoo.com wrote:
> Thanks all for the answers. Yup, i think i will use dicts/tuples/lists
> instead...

Even though you should be using some kind of container, you can still
do what you origianlly asked for with relative ease...you just have to
use the evil eval function (gasp!):

for i in xrange(5):
  if i == 0: continue
  print eval("var%d" % i)

Regards,
Jordan




More information about the Python-list mailing list