- __init__
- self
Init uses same name as attribute and getters
examples/oop/attributes/shapes2.py
class Point: def __init__(self, x, y): self.x = x self.y = y
examples/oop/attributes/use_shapes2.py
from shapes2 import Point p1 = Point(2, 3) print(p1) # <shapes2.Point object at 0x7f2c22c1ec70> print(p1.x) # 2 print(p1.y) # 3 p2 = Point(y=7, x=8) print(p2) # <shapes2.Point object at 0x7f2c22c1e700> print(p2.x) # 8