

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- How do I enumerate functions of a Python class?
- How to get a list of all the test methods in a TestNG class?
- How do I get length of list of lists in Java?
- How do we get size of a list in Python?
- How do I list all files of a directory in Python?
- How do I declare a global variable in Python class?
- List methods of a class using Java Reflection
- How do we get the size of a list in Python?
- How do I chain methods in PHP?
- How can I get a list of locally installed Python modules?
- How do I make a subclass from a super class in Python?
- How do I get time of a Python program's execution?
- How do I empty a list in Java?
- How do I search a list in Java?
- How do I get the parent directory in Python?
Advertisements