Perl is worse!

Steve Lamb grey at despair.rpglink.com
Fri Jul 28 04:11:18 EDT 2000


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.  

    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?  If it is a string that cannot be converted to an integer, throw an
exception, otherwise, do it.  Then that preserves the 1 + "foo" exception and
also does the sane thing of getting rid of types when it makes sense to do so.

    Hell, why do an exception at all?  Why not do what is already done with
integers, reals and floats?  

1 + 1 = math

1 + "1" = math

1 + "foo" = string ("1foo")

"foo" + "foo" = string ("foofoo")

    You already accept:

1 + 1 = integer

1 + 1.2 = float

1 + 1j = complex

    So please don't tell me you don't want "automagic" type changing when it
is already there and, I'd wager, you use it extensively.

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
         ICQ: 5107343          | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list