Python Objects
OOP Core
Working with Objects
Every class instantiates objects. Understand identity, equality, and lifecycle events for predictable behavior.
Lifecycle
__new__allocates memory (rarely overridden).__init__initializes attributes.__repr__/__str__render human-readable info.__del__runs when garbage collected (avoid heavy logic).
Identity vs equality
a = Invoice(100, "Ada")
b = Invoice(100, "Ada")
print(a is b) # False
print(a == b) # Depends on __eq__
Mutable objects share references; copy them when needed.