Q:

Is it possible to print a function as a string in Python? 

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? 

A:

You can do it, but the result isn't useful since everything is compiled to bytecode first. 
def printItself():
    print repr(printItself.func_code.co_code)

You can also use the dis module for disassembly, but the results aren't garuenteed to be portable. 
def disassembleItself():
    print __import__('dis').dis(disassembleItself)

