- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do I get list of methods in a Python class?
The following code prints the list of methods 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 a list of all instances of a given class in Python?
- How do I create static class data and static class methods in Python?
- How to get a list of all the test methods in a TestNG class?
- How do I enumerate functions of a Python class?
- How do we get size of a list in Python?
- How do I get length of list of lists in Java?
- How do we get the size of a list in Python?
- How do I create a multidimensional list in Python?
- How do I declare a global variable in Python class?
- How do I list all files of a directory in Python?
- List methods of a class using Java Reflection
- How do I make a subclass from a super class in Python?
- How can I get a list of locally installed Python modules?
- How do I use strings to call functions/methods in Python?
- How do I chain methods in PHP?

Advertisements