Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import functools as ft
  2.  
  3. @ft.total_ordering
  4. class version:
  5.     def __init__(self, v):
  6.         self.vs = [int(p) for p in v.split('.')]
  7.  
  8.     def __cmp__(self, other):
  9.         ds = [d for d in map(lambda a, b: a - b, self.vs, other.vs) if d]
  10.         return ds[0] // abs(ds[0]) if ds else 0
  11.  
  12.     def __eq__(self, other): return self.__cmp__(other) == 0
  13.     def __gt__(self, other): return self.__cmp__(other) == 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement