> def f1(): > print "In f1" > > def f3(): > print "In f3" > > def others(): > print "In others" > > for i in xrange(1,3): > fct = "f%d()"%(i+1) > try: > exec fct > except: > others()
I'd write that as for i in xrange(1,3): globals().get("f%d" % (i+1), others)() Regards, Martin -- http://mail.python.org/mailman/listinfo/python-list