Hi Stewart,
what about the other way, string -> var and not var -> string?
My suggestion: mylist = ["a", "b", "c"] for my in mylist: if locals()[my] == None: print "you have a problem with %s" % my
Paolo
Stewart Midwinter wrote:
I'd like to do something like the following:
a = 1; b = 2; c = None mylist = [a, b, c] for my in mylist: if my is None: print 'you have a problem with %s' % my #this line is problematic
You have a problem with None
What I want to see in the output is:
You have a problem with c
How do I convert a variable name into a string?
thanks!
-- http://mail.python.org/mailman/listinfo/python-list