'20' <= 100

John Roth johnroth at ameritech.net
Thu May 1 19:19:06 EDT 2003


"Gerhard Häring" <gh at ghaering.de> wrote in message
news:mailman.1051827724.20132.python-list at python.org...
> Dave Brueck wrote:
> > [...] Put another way, if you give Python:
> >
> > s = '20'
> > t = 2
> > x = s * t
> >
> > How can it know that you expected 40 instead of '2020'?
>
> Sure, but if you give Pyhthon:
>
> s = '20'
> t = 2
> if s < 6:
> ...
>
> like the OP did, Python should tempt the tempation to guess, like it
> usually does. The comparison operators should IMO be changed to raise
a
> TypeError in this case.
>
> strings should only be comparable to other basestrings and numbers
> should only be comparable to other number types.
>
> Does anyone disagree? Why?

I'm sure you remember this dead horse being flogged numerous
times in the past. The upshot is that sort needs a reliable method
of ordering heterogenous objects.

I wouldn't mind having both a "strict" and a "non-strict" comparison,
but that would be enough of a major language change that it would
need quite a bit of discussion.

John Roth
>
> -- Gerhard
>






More information about the Python-list mailing list