wormwood_3 wrote:
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.
Python does not store the source when compiling things. So the short
answer is NO.
There are some "disassemblers" for Python but I have no experience with
them. They will not be able to reconstruct the exact source.
But ... why do you want to do this? Perhaps if we had more information
about the "use case" we could steer you to a solution.
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
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
--
Bob Gailer
Chapel Hill NC
919-636-4239
|
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor