from functools import total_ordering from abc import ABCMeta,abstractmethod @total_ordering class Shape(object): @abstractmethod def area(self): pass def __eq__(self,obj): return self.area()==obj.area() def __lt__(self,obj): return self.are
from abc import ABCMeta,abstractmethod
@total_ordering
class Shape(object):
@abstractmethod
def area(self):
pass
def __eq__(self,obj):
return self.area()==obj.area()
def __lt__(self,obj):
return self.area()<obj.area()
class Rectangle(Shape):
def __init__(self,w,h):
self.w=w
self.h=h
def area(self):
return self.w*self.h
class Circle(Shape):
def __init__(self,r):
self.r=r
def area(self):
return 3.14*self.r*self.r
r1=Rectangle(5,1)
r2=Rectangle(1,4)
c1=Circle(4)
c2=Circle(3)
print(r1>=r2,c1>c2)