3 Ways to Explore a Python Object
Introduction
When we get a reference of a Python object, how can we know the information about it? Of course, we can read its source code. However, sometimes we don’t have enough time to read it or even we just get this object from an API and cannot access its source code.
This post will introduce three ways to have a quick check of a Python object.
1. Get the Type Information of Objects
First of all, when we get an object, we can check which type it belongs to by type()
method.
Since the type()
method returns an object’s type, it can be used to compared two types.
Note: In the above example, we compared type(b)==int
and got a True
. If we compare type(b)==type(int)
, a False
will be printed. Because the…