[Python-3000] a plea : invalid comparisons should raise an exception

Collin Winter collinw at gmail.com
Mon Apr 23 19:12:03 CEST 2007

On 4/23/07, Helmut Jarausch <jarausch at igpm.rwth-aachen.de> wrote:
> Some years ago, I was allured to convert from Perl to Python.
> The main argument was that Python is much more secure.
> That turned out to be true with one big exception.
> The following lines would run just fine (as equivalent
> Perl code)
> from cStringIO import StringIO
> Inp= StringIO('Guido 10')
> for line in Inp:
>     (Name,Age)= line.split()
>     if Age > 64 :
>         print Name,"has retired"
> But with Python it returns a very unexpected result
> without any evidence of a problem.
> So, please make comparisons raise an exception (at least
> optionally) if "uncompatible" types are compared.

This is already going to happen; see
http://www.python.org/dev/peps/pep-3100/#core-language, 12th bullet

Collin Winter

More information about the Python-3000 mailing list