Created
August 26, 2014 21:01
-
-
Save singingwolfboy/8cf15e1d575586226451 to your computer and use it in GitHub Desktop.
inspect.getmembers() does not seem to be working on Python 3.4 with the predicate argument -- I would expect the last call to return information for `a` and `b`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% python3 | |
Python 3.4.1 (default, May 19 2014, 13:10:29) | |
[GCC 4.2.1 Compatible Apple LLVM 5.1 (clang-503.0.40)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> class Foo(object): | |
... def a(self): | |
... pass | |
... def b(self, nothing): | |
... pass | |
... | |
>>> import inspect | |
>>> inspect.getmembers(Foo) | |
[('__class__', <class 'type'>), ('__delattr__', <slot wrapper '__delattr__' of 'object' objects>), ('__dict__', mappingproxy({'__weakref__': <attribute '__weakref__' of 'Foo' objects>, 'b': <function Foo.b at 0x10e2168c8>, '__module__': '__main__', '__doc__': None, '__dict__': <attribute '__dict__' of 'Foo' objects>, 'a': <function Foo.a at 0x10e216840>})), ('__dir__', <method '__dir__' of 'object' objects>), ('__doc__', None), ('__eq__', <slot wrapper '__eq__' of 'object' objects>), ('__format__', <method '__format__' of 'object' objects>), ('__ge__', <slot wrapper '__ge__' of 'object' objects>), ('__getattribute__', <slot wrapper '__getattribute__' of 'object' objects>), ('__gt__', <slot wrapper '__gt__' of 'object' objects>), ('__hash__', <slot wrapper '__hash__' of 'object' objects>), ('__init__', <slot wrapper '__init__' of 'object' objects>), ('__le__', <slot wrapper '__le__' of 'object' objects>), ('__lt__', <slot wrapper '__lt__' of 'object' objects>), ('__module__', '__main__'), ('__ne__', <slot wrapper '__ne__' of 'object' objects>), ('__new__', <built-in method __new__ of type object at 0x10df31e20>), ('__reduce__', <method '__reduce__' of 'object' objects>), ('__reduce_ex__', <method '__reduce_ex__' of 'object' objects>), ('__repr__', <slot wrapper '__repr__' of 'object' objects>), ('__setattr__', <slot wrapper '__setattr__' of 'object' objects>), ('__sizeof__', <method '__sizeof__' of 'object' objects>), ('__str__', <slot wrapper '__str__' of 'object' objects>), ('__subclasshook__', <built-in method __subclasshook__ of type object at 0x7fd4dad002f8>), ('__weakref__', <attribute '__weakref__' of 'Foo' objects>), ('a', <function Foo.a at 0x10e216840>), ('b', <function Foo.b at 0x10e2168c8>)] | |
>>> inspect.getmembers(Foo, predicate=inspect.ismethod) | |
[] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment