fork(1) download
  1. class myFloat(float):
  2. def __add__(self, value):
  3. if type(value) is str:
  4. return float.__add__(self, float(value))
  5. else:
  6. return float.__add__(self, value)
  7.  
  8. def __radd__(self, value):
  9. return self.__add__(value)
  10.  
  11. x = myFloat(1.0)
  12. print(x + '1.5')
Success #stdin #stdout 0.03s 9440KB
stdin
Standard input is empty
stdout
2.5