What is an object id in Python?

Questions & AnswersCategory: PythonWhat is an object id in Python?
Geek Boy Staff asked 2 years ago

What is an object id in Python?
a. An object id is a float number that guarantees that it will be unique and constant for that object throughout its lifetime.
b. An object id is an integer that guarantees that it will be unique and constant for that object throughout its lifetime.
c. An object id is an integer and does not guarantee that it will be unique and constant for that object throughout its lifetime.

1 Answers
Geek Boy Staff answered 2 years ago

b. An object id is an integer that guarantees that it will be unique and constant for that object throughout its lifetime.

Explanation:

id(object) – return the “identity” of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value.