On this page
id
Prev: hex | Up: __builtins__ | Next: input
Rel: callable, delattr, dir, getattr, hasattr
Ref: docs.python.org — id
Tags: #public #python3 #builtins
Import & Availability
# Built-in (available globally without import)
from builtins import id
Overview & Signature
id(obj, /)
Return the identity of an object.
Usage
a = [1, 2]
b = a
assert id(a) == id(b) and a is b
Gotchas
- IDs are recycled after garbage collection: Only unique among concurrently alive objects—use
is/is notfor identity checks.
REPL Inspect
help(id)
Linked from
Related notes
- tuts/python3/__builtins__/__builtins__ Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/hex Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__/input Linked here; links to this page; shared tags: #builtins
- tuts/python3/__builtins__ links to this page; shared tags: #builtins
- tuts/python3/__builtins__/callable Linked here; shared tags: #builtins
- tuts/python3/__builtins__/delattr Linked here; shared tags: #builtins
- tuts/python3/__builtins__/dir Linked here; shared tags: #builtins
- tuts/python3/__builtins__/getattr Linked here; shared tags: #builtins
- tuts/python3/__builtins__/hasattr Linked here; shared tags: #builtins
- tuts/python3/python fundamentals links to this page