Printing literal text of an argument

Rex Eastbourne rex.eastbourne at gmail.com
Thu Aug 11 22:46:36 EDT 2005


Thanks. I adapted it a bit:

def debug(foo):
    print foo, 'is:'
    exec('pprint.pprint(' + foo + ')')

But I'm getting "NameError: name 'foo' is not defined," since foo is
not defined in this scope. (The function works beautifully when I'm
dealing with global variables, which is very rarely).

Any way around this?

Rex




More information about the Python-list mailing list