[Tutor] Printing the code of a function

wormwood_3 wormwood_3 at yahoo.com
Mon Dec 29 02:49:59 CET 2008


Hello all,

This might be trivially easy, but I was having a hard time searching on it since all the component terms are overloaded:-) I am wondering if there is a way to print out the code of a defined function. So if I have:

def foo():
    print "Show me the money."

then I would like to do something like:

>>> foo.show_code
def foo():
    print "Show me the money."

I checked out everything in dir(foo), but everything that looked promising (namely foo.func_code), didn't end up being anything close.

Thanks for any help!

Cordially,
Sam

 _______________________
Samuel Huckins


Homepage - http://samuelhuckins.com
Tech blog - http://dancingpenguinsoflight.com/
Photos - http://www.flickr.com/photos/samuelhuckins/
AIM - samushack | Gtalk - samushack | Skype - shuckins
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20081228/1a5ca929/attachment.htm>


More information about the Tutor mailing list