开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜