Python self-evaluating strings

dg.google.groups at thesamovar.net dg.google.groups at thesamovar.net
Sun Jan 27 13:47:13 EST 2008


It's a bit cheap, but how about

>>> from inspect import getsource
>>> print getsource(getsource)

or similarly

def f(g):
    import inspect
    return inspect.getsource(g)
print f(f)

Dan



More information about the Python-list mailing list