Python id() Function

Example

Returns the unique id of the tuple object:

x = ('apple', 'banana', 'cherry')
y = id(x)

Running Instance

Definition and Usage

The id() function returns the unique id of the specified object.

All objects in Python have their own unique id.

id is allocated to the object at the time of creation.

id is the memory address of the object and is different each time the program runs. (Except for certain objects with a constant unique id, such as integers from -5 to 256)

Syntax

id(object)

Parameter Value

Parameter Description
object Any object, string, number, list, etc.