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:
How do I convert a variable name into a string?

I think you actually want the opposite:

    a = 1; b = 2; c = None
    mylist = ['a', 'b', 'c']
    for my in mylist:
        if globals()[my] is None:
            print 'you have a problem with %s' % my
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to