Inspect Object
Learn how to inspect an object in Python and Powershell.
We'll cover the following
inspect
Module in Python
Python is also equipped with a library called inspect
, which can be utilized to find the members of live Python objects. This can even be done during program execution.
The following are some useful methods provided by this module that can check if any object or members of the object is a module, class, function, etc. by using the Boolean output True
or False
:
ismodule()
isclass()
ismethod()
isfunction()
isgeneratorfunction()
isgenerator()
istraceback()
isframe()
iscode()
isbuiltin()
For example, if we pass the os
module to the ismodule()
method, we’ll get True
as the output. When we pass another object, let’s say a string, we’ll get the output as False
.
Get hands-on with 1400+ tech skills courses.