Skip to content

Python print methods of object | Example code

  • by

The simplest method is to use dir(object_name) to get all the methods available for that object and use the print method to print it.

Python print methods of object example

A simple example code uses the built-in dir() function to get a list of all the attributes a module has. Try this at the command line to see how it works.

>>> import moduleName
>>> dir(moduleName)

Or in programming

import pandas as pd

res = dir(pd)

Print the method of the String object

a = "I am a string"

res = dir(a)


Python print methods of object

Another example

The simplest way to get a list of methods of any object is to use the help() command.


It will list out all the available/important methods associated with that object.

For example:

# or
res = help(str)

Do comment if you have any doubts or suggestions on this Python object code.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Discover more from Tutorial

Subscribe now to keep reading and get access to the full archive.

Continue reading