Symbols count in article: 226Reading time ≈1 mins.
OOP
获取类的属性、方法、函数等
inspect 包
1 2 3 4
# get the attributes which are not class method attrs = inspect.getmembers(self, lambda x: not inspect.ismethod(x)) # filter the private attributes attrs = [x[0] for x in filter(lambda x: not x[0].startswith('__'), attrs)]