id() is an inbuilt function in Python.
As we can see the function accepts a single parameter and is used to return the identity of an object. This identity has to be unique and constant for this object during the lifetime. Two objects with non-overlapping lifetimes may have the same id() value. If we relate this to C, then they are actually the memory address, here in Python it is the unique id. This function is generally used internally in Python.
The output is the identity of the object passed. This is random but when running in the same program, it generates unique and same identity. Input : id(1025) Output : 140365829447504 Output varies with different runs Input : id("geek") Output : 139793848214784
140252505691448 140252505691448 True 140252505691840 140252505739928 False
- Wand function() function in Python
- Python - Call function from another function
- Python tell() function
- Python | int() function
- Python | now() function
- sum() function in Python
- Help function in Python
- ord() function in Python
- Python | hex() function
- Python map() function
- Python | dir() function
- Python | oct() function
- Python | cmp() function
- Python | How to get function name ?
- Python | math.cos() function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.