float_compare.py 288 B

12345678910111213141516171819202122
  1. # Extended float comparisons
  2. class Foo:
  3. pass
  4. foo = Foo()
  5. print(foo == 1.0)
  6. print(1.0 == foo)
  7. print(1.0 == Foo)
  8. print(1.0 == [])
  9. print(1.0 == {})
  10. try:
  11. print(foo < 1.0)
  12. except TypeError:
  13. print("TypeError")
  14. try:
  15. print(1.0 < foo)
  16. except TypeError:
  17. print("TypeError")