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
- Help function in Python
- Python | oct() function
- Python | now() function
- Python | hex() function
- ord() function in Python
- Python | cmp() function
- Python | dir() function
- Python map() function
- sum() function in Python
- Python | int() function
- Python | How to get function name ?
- Currying Function in Python
- Python statistics | mean() function
- Python | frexp() Function
- Function Annotations in Python
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.