Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import functools as ft
- @ft.total_ordering
- class version:
- def __init__(self, v):
- self.vs = [int(p) for p in v.split('.')]
- def __cmp__(self, other):
- ds = [d for d in map(lambda a, b: a - b, self.vs, other.vs) if d]
- return ds[0] // abs(ds[0]) if ds else 0
- def __eq__(self, other): return self.__cmp__(other) == 0
- def __gt__(self, other): return self.__cmp__(other) == 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement