Python: Get a list of methods for an object

How to get all the method names of an object in Python.

print type(obj)
for x in inspect.getmembers(obj, inspect.ismethod):
  print x[0]

Output example


<class 'nfc.tag.tt3_sony.FelicaStandard'>
__init__
__str__
_format
_is_present
authenticate
dump
dump_service
format
polling
protect
read_from_ndef_service
read_without_encryption
request_response
request_service
request_system_code
search_service_code
send_cmd_recv_rsp
write_to_ndef_service
write_without_encryption

He also introduced the method using dir in the comment.

for x in dir(obj):
    print x, ':', type(eval("obj."+x))

Thank you for reading to the end. On Twitter, we also tweet technical material that is not written in Qiita, so please follow us if you like: relieved: → Twitter @ suin

Recommended Posts

Python: Get a list of methods for an object
[python] Get a list of instance variables
[Python] Get a list of folders only
Python script to get a list of input examples for the AtCoder contest
Get the attributes of an object
Get the number of specific elements in a python list
Get a list of purchased DMM eBooks with Python + Selenium
Since Python 1.5 of Discord, I can't get a list of members
How to get a list of built-in exceptions in python
Turn an array of strings with a for statement (Python3)
Try to get a list of breaking news threads in Python.
Display a list of alphabets in Python 3
Get a token for conoha in python
Summary of built-in methods in Python list
Get a list of CloudWatch Metrics and a correspondence table for Unit units with Python boto
Get a list of files in a folder with python without a path
Get a list of packages installed in your current environment with python
Get a ticket for a theme park with python
Get the caller of a function in Python
Get a list of IAM users with Boto3
Get a list of Qiita likes by scraping
Get a glimpse of machine learning in Python
Insert an object inside a string in Python
List of python modules
[Python] Create a list of date and time (datetime type) for a certain period
Get a list of articles posted by users with Python 3 Qiita API v2
How to get a list of files in the same directory with python
[Introduction to Python] How to get the index of data with a for statement
Convert a slice object to a list of index numbers
List of Python libraries for data scientists and data engineers
List of sample program distribution sites for python books
[python] Get the list of classes defined in the module
How to write a list / dictionary type of Python3
Nothing remains after making a python map object a list
[Python] Get the list of ExifTags names of Pillow library
Group by consecutive elements of a list in Python
A python regular expression, or a memo of a match object
Get an abstract understanding of Python modules and packages
Create a shape on the trajectory of an object
Get the value of a specific key in a list from the dictionary type in the list with Python
Python list, for statement, dictionary
Summary of Python3 list operations
[python] Value of function object (?)
Python list is not a list
[Python] Copy of multidimensional list
[Python / PyQ] 4. list, for statement
Python #list for super beginners
Make an IP address allocation / allocation list for a certain area
Try to get the function list of Python> os package
[Python] How to make a list of character strings character by character
[Python] Create a date and time list for a specified period
Developed a library to get Kindle collection list in Python
How to make a Python package (written for an intern)
[Python] Countermeasures for "AttributeError:'NoneType' object has no attribute'group'" of googletrans
How to get the last (last) value in a list in Python
Get index of nth largest / smallest value in list in Python
Python: Create a dictionary from a list of keys and values
Get the number of occurrences for each element in the list
How to get a list of links from a page from wikipedia
[Python] List of major destructive methods of list operation (addition / deletion / sorting)
Get index of nth largest / smallest value in list in Python