1
Fork 0
mirror of https://github.com/Steffo99/greed.git synced 2024-12-01 01:54:18 +00:00
greed/dbcomposites.py

19 lines
622 B
Python
Raw Normal View History

2017-08-30 18:47:15 +00:00
# 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