Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 559 Bytes

File metadata and controls

21 lines (14 loc) · 559 Bytes

Classes

Basic object-oriented programming in Python. See Class (computer programming) — Wikipedia.

Key methods

Method Purpose
__init__ Constructor — initialises the object's attributes
__str__ Controls what print(obj) displays
__eq__ Controls how == compares two objects

Example: Line class

Represents a line segment between two 2D points. Computes the Euclidean distance between them.

Run

python classes.py