Python object Error

Sometime when I print some variable in python I get a message saying < … object at 0x0000012A26D2DA60>". and I don’t know how to deal with it.
I searched a lot on internet but did not got the sufficient answer, So can anyone help me to understand this message. Any documentation or Tutorial would be highly appreciated.

PS: When I dig deep in internet I found that this message arises when we print the object of some class. I also used python command “dir(object_name)” to see what is inside the object but still don’t know how to work with it.

That’s just the default representation of objects that don’t implement their own __repr__ method. It’s not an error, so you don’t need to deal with it.

Some more details:

  • It is __repr__ of the base object class. Classes which do not implement their own __repr__ inherit it from their parent class and it could be the base implementation from the object class.
  • The hexadecimal number shown is a unique (during the time of the object existence) identification of the object.


$ python3
Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> obj = object()
>>> obj
<object object at 0x7f4f1e5a8880>
>>> hex(id(obj))