Python 3 raising an error where Python 2 did not

dfh at forestfield.co.uk dfh at forestfield.co.uk
Fri Aug 26 04:50:54 EDT 2016


In a program I'm converting to Python 3 I'm examining a list of divisor values, some of which can be None, to find the first with a value greater than 1.

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> None > 1
False

Python 3.4.4 (v3.4.4:737efcadf5a6, Dec 20 2015, 20:20:57) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> None > 1
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unorderable types: NoneType() > int()

I can live with that but I'm curious why it was decided that this should now raise an error.

David Hughes
Forestfield Software



More information about the Python-list mailing list