Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Methods

class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

    def move(self, dx, dy):
        self.x += dx
        self.y += dy
from shapes import Point

p1 = Point(2, 3)
print(p1.x)    # 2
print(p1.y)    # 3

p1.move(4, 5)
print(p1.x)    # 6
print(p1.y)    # 8


print(p1)      # <shapes.Point object at 0x7fb0691c3e48>