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
- sum() function in Python
- Python | How to get function name ?
- Help function in Python
- Python map() function
- ord() function in Python
- Python | cmp() function
- Python | dir() function
- Python | int() function
- Python | now() function
- Python | oct() function
- Python | hex() function
- Sorted() function in Python
- Python | fsum() function
- How to Call a C function in Python
- round() function 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 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.