Perl is worse!

Garry Hodgson garry at sage.att.com
Fri Jul 28 13:25:36 EDT 2000


Steve Lamb wrote:
> 
> On Fri, 28 Jul 2000 01:24:08 -0400, Tim Peters <tim_one at email.msn.com> wrote:
> >Steve, in case it isn't clear yet, Python programmers *want* to be blown out
> >of the water when doing something as senseless as
> 
> >    1 + "foo"
> 
>     It isn't senseless.  That is the whole point.  It is only senseless
> because of typing.  Clearly you cannot add a word to a number, granted.  But
> what of 1 + "1"?  That isn't senseless, those are two numbers.  I can see they
> are two numbers, it is only because of typing that it fails.

you can see that because you are smarter than my computer.  in the
general case,
adding an integer to a string is, indeed, nonsense.  it also likely, or
at least
possible, that it represents a programming error.  the choice python
makes is
to alert the programmer to this (possible) error, and make them
explicitly
override this if that is really what they want to do.

1 + "1" might mean 2, or it might be an error.
1 + "foo" might mean "1foo", or it might be an error.

the system can't know which i intended, so it makes be specify.
it is much easier to say, "yes, i meant that" by adding a cast,
than to debug an errant program, possibly years later.

>     So I ask you this /VERY/ simple question.  Why can't Python do both?  Hm?
> What is wrong with taking 1 + "1", converting the "1" to a 1 and adding it
> together?

see above.

-- 
Garry Hodgson                   Every night 
garry at sage.att.com                a child is born
Software Innovation Services        is a Holy Night.
AT&T Labs                         - Sophia Lyon Fahs



More information about the Python-list mailing list