On Sun, Dec 28, 2008 at 8:49 PM, 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.
If the source code is av
On Mon, 29 Dec 2008 09:18:43 -
"Alan Gauld" wrote:
>
> "wormwood_3" wrote
>
> > I am wondering if there is a way to print out the code of a defined
> > function.
>
> Its not reliable but I think you can use
>
> func.func_code.filename
> func.func_code.firstlineno
>
> To find the first
"wormwood_3" wrote
I am wondering if there is a way to print out the code of a defined
function.
Its not reliable but I think you can use
func.func_code.filename
func.func_code.firstlineno
To find the first line of code in the original source file.
Its up to you to figure out the last line
kype - shuckins
From: bob gailer
To: wormwood_3
Cc: tutor@python.org
Sent: Sunday, December 28, 2008 9:07:12 PM
Subject: Re: [Tutor] Printing the code of a function
wormwood_3 wrote:
Hello
all,
This might be trivially easy, but I was having a hard time searching on
it since al
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 thing
wormwood_3 wrote:
> I am wondering if there is a way to
> print out the code of a defined function.
When Python compiles source code, it doesn't store the source code
itself; only the compiled intermediate code. With the 'dis' package you
can disassemble that:
def foo():
print "Show me
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 so