apihelper 查看属性和方法
2009-09-04 17:03
211 查看
def info(object,spacing=20,collapse=1):
"""print methods and doc string.
takes module,class,list,dictionary,or string."""
methodList=[method for method in dir(object) if hasattr(getattr(object,method),'__call__')]
processFunc=collapse and (lambda s:" ".join(s.split())) or(lambda s:s)
print("/n".join(["%s %s"%(method.ljust(spacing),processFunc(str(getattr(object,method).__doc__)))for method in methodList]))
if __name__=="__main__":
print(info.__doc__)
Python3.1没有了callable 但是我们可以用hasattr(method,‘__call__')代替它
processFunc 如果你用type去查看 发现他是一个引用
而processFunc()这个函数呢 就相当与c++里面的 c?a:b
"""print methods and doc string.
takes module,class,list,dictionary,or string."""
methodList=[method for method in dir(object) if hasattr(getattr(object,method),'__call__')]
processFunc=collapse and (lambda s:" ".join(s.split())) or(lambda s:s)
print("/n".join(["%s %s"%(method.ljust(spacing),processFunc(str(getattr(object,method).__doc__)))for method in methodList]))
if __name__=="__main__":
print(info.__doc__)
Python3.1没有了callable 但是我们可以用hasattr(method,‘__call__')代替它
processFunc 如果你用type去查看 发现他是一个引用
而processFunc()这个函数呢 就相当与c++里面的 c?a:b
相关文章推荐
- 编译java文件的时候出现API已过时的提示,查看是哪个方法过时的具体操作
- APIHelper的使用方法
- MyEclipse中解决不能查看源代码或者API帮助文档的方法
- Java查看API和源码的方法
- OLE/COM 对象查看器——查看已注册控件的属性和方法(自己整理)
- 低api中使用View的属性设置方法如setAlpha
- html5新属性,事件,API方法 笔记1.
- 【iOS开发-25】UIDevice查看系统信息,从一个问题開始怎样高速找到自己想要的属性和方法并看懂它
- IP Helper API 使用方法
- python selenium api 源码查看方法
- 如何在低api中使用View的属性设置方法如setAlpha等
- 编译java文件的时候出现API已过时的提示,查看是哪个方法过时的具体操作
- DOM常用API、属性、方法、函数
- MyEclipse中解决不能查看源代码或者API帮助文档的方法
- Eclipse学习笔记之如何查看某个属性和方法在哪些地方用到了
- Linux下七种文件类型、文件属性及其查看方法
- 在eclipse中查看一个类及其父类中的所有方法和属性
- Java利用反射查看类属性和方法例子
- Jquery的api中提供了对元素应用disabled和readonly属性的方法
- flex官网api,包含属性方法,实例,非常全