Skip to content

Glossary: Python Beyond the Basics

__eq__ / __lt__

Also written: __eq__, __lt__

Special methods that define what `==` and `<` mean for your own objects. Python also uses `__lt__` when sorting, so a Product with `__lt__` can be sorted by price.

Where the book teaches it

Related terms

special methoddataclassNotImplemented