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
- Python - Call function from another function
- Wand function() function in Python
- Python tell() function
- Python | int() function
- sum() function in Python
- ord() function in Python
- Python | How to get function name ?
- Python | oct() function
- Python | cmp() function
- Python | dir() function
- Help function in Python
- Python | hex() function
- Python | now() function
- Python map() function
- Python strftime() function