Python id()

Python id() builtin function returns an integer representing the identity of given object.

Each object in a program, during execution of the program, is assigned an integer unique to an object. This id may change from one program execution instance to another.

In this tutorial, we will learn about the syntax of Python id() function, and learn how to use this function with the help of examples.

Syntax

The syntax of id() function is

</>
Copy
id(object)

where

ParameterRequired/OptionalDescription
objectRequiredA python object whose id has to be found out.

Returns

The function returns an int object.

Example

In this example, we will take a Python object, say a list, and find its unique id using id() builtin function.

Python Program

</>
Copy
myList = [24, 0, 8, 6]
result = id(myList)
print(f'Unique id of this list object is {result}.')

Output

Unique id of this list object is 2382951703176.

Conclusion

In this Python Tutorial, we have learnt the syntax of Python id() builtin function, and also learned how to use this function, with the help of Python example programs.