开发者

Previewing the class or function definition source code in the interactive shell

开发者 https://www.devze.com 2023-03-22 14:07 出处:网络
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?

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

精彩评论

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