Comparison of different types does not throw exception

Nils O. Selåsdal noselasd at frisurf.no
Fri Jul 13 12:30:55 CEST 2001


"Gordon Williams" <g_will at cyberus.ca> wrote in message
news:mailman.994953783.6278.python-list at python.org...
> I would like to know why python does not produce an exception when a
> comparison of objects of different types is made.  For example:
>
> >>> 1 < "aaa"
> 1
>
> I cant see why anyone would like to have comparisons of different
types as
> it has no meaning.  It is a programming error and an exception should
be
> produced.
>
> This one tripped me up in an assert statement for a couple of hours.
The
> assert statement was returning true when it should have been false to
give
> me a warning that there was a problem.  It was something like:
>
> lengthA= 3
> lengthB= "2"
>
> assert lengthA <= lengthB
>
> and was returning true
In any OO language its desired to take advantage og polymorphisme,
and let comparison between diffrent objects be allowed.The programmer
is responsible,
for providing comparison functions.
I wanna know if my User also equals my SecureUser....






More information about the Python-list mailing list