Possible Duplicate:
Can Python print a function definition?
In Javascript, it is possible to print a function’s code as a string?
Example in Javascript:
function thisFunctionPrintsItself(){
return thisFunctionPrintsItself.toString();
}
Is it possible to do the same in Python?
You can do it, but the result isn’t useful since everything is compiled to bytecode first.
You can also use the
dismodule for disassembly, but the results aren’t garuenteed to be portable.