"wormwood_3" <wormwoo...@yahoo.com> 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 though! I guess checking
for the next line with equivalent indentation might work.

But I'm not sure how much good it would do you... unless you
were writing a debugger maybe?

Alan G


_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to