निम्न कोड दिए गए क्लास के फ़ंक्शन की सूची प्रिंट करता है:
उदाहरण
class foo:
def __init__(self):
self.x = x
def bar(self):
pass
def baz(self):
pass
print(type(foo))
import inspect
print(inspect.getmembers(foo, predicate=inspect.ismethod))
आउटपुट
आउटपुट निम्न है:
<type 'classobj'> [('__init__', <unbound method foo.__init__>), ('bar', <unbound method foo.bar>), ('baz', <unbound method foo.baz>)]