1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-11-30 17:44:18 +00:00
greed/dbcomposites.py

19 lines
No EOL
622 B
Python

# Custom composite types
# All types must contain the __composite_values__ method
class Coordinates(object):
"""Geographic coordinates"""
def __init__(self, longitude, latitude):
self.longitude = longitude
self.latitude = latitude
def __repr__(self):
return f"Coordinates(longitude={self.longitude}, latitude={self.latitude})"
def __eq__(self, other):
return isinstance(other, Coordinates) \
and self.longitude == other.longitude \
and self.latitude == other.latitude
def __composite_values__(self):
return self.longitude, self.latitude