[英]Previewing the class or function definition source code in the interactive shell
Is it possible to access a source code of the imported class or funciton while using interactive shell like IDLE Shell or Linux python? 使用诸如IDLE Shell或Linux python之类的交互式Shell时是否可以访问导入的类或函数的源代码?
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.