Previewing the class or function definition source code in the interactive shell
Is it possible to access a source code of the imported clas开发者_StackOverflow社区s or funciton while using interactive shell like IDLE Shell or Linux python?
In example, I wish that it was possible to do the following:
from myClasses import MyClass
#this
print MyClass.__source__
#or that
source(MyClasss)
# would result in:
def MyClass(object):
pass
from myClasses import MyClass
import inspect
source = inspect.getsource(MyClass)
print source
#class MyClass(object):
# pass
精彩评论