The id() function in Python

The id() function in Python


OMG. Today I learned about something amazing new in Python called id(). It is so so so amazing and incredible.I read that "The id function in Python plays a unique and powerful role as it allows you to obtain the identity of an object. Every object in Python has a unique identity, a number that distinguishes it from all other objects during its lifetime. This identity is assigned when an object is created and remains constant throughout its existence."

WOW WOW WOOOOOW

"The id function in Python provides a way to access this identity, allowing you to verify whether two variables reference the same object and to gain insights into object behaviour and memory management."

Basically put:

"id() is a built-in Python method that returns a unique id for given object, and this id must be unique throughout the object's lifespan.
In Python, each object and variable has a unique id." Yeah no I'm done this is completely amazing. I'm checking out. Wooooooow! This is such an amazing tool for debugging and for learning to code because you can check if two variables point to the same object in memory.

Whatcha got, javascript???!

Source: all quotations come from this link.

A pink and yellow picture of code in the background. Text reads: id() in Python.  Provides a unique identifier code for every object in Python  Helps you to identify whether two variables in Python point to the same object in memory.


Comments