
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
How do I enumerate functions of a Python class?
The following code prints the list of functions of the given class as follows
Example
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))
Output
The output is
<type 'classobj'> [('__init__', <unbound method foo.__init__>), ('bar', <unbound method foo.bar>), ('baz', <unbound method foo.baz>)]
- Related Articles
- How do I get list of methods in a Python class?
- How do I declare a global variable in Python class?
- How do I make a subclass from a super class in Python?
- How do I get a list of all instances of a given class in Python?
- How do I use strings to call functions/methods in Python?
- Enumerate() in Python
- How do I create static class data and static class methods in Python?
- First Class functions in Python
- How do nested functions work in Python?
- How to create Python dictionary by enumerate function?
- Synthesis of MHC class I molecules Their types and functions
- How exactly do Python functions return/yield objects?
- How do I write class names in Java?
- How do I create a Python namespace?
- How do we reference Python class attributes?

Advertisements