Perl is worse!

Tim Peters tim_one at email.msn.com
Fri Jul 28 18:46:08 EDT 2000


[Tim]
> 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"

[Steve Lamb]
>     It isn't senseless.  That is the whole point.

Indeed it is.  In fact, it has too *many* senses for Python's tastes.  You
think it "should" return 1, or (in other posts) raise an exception.  Someone
coming from Java thinks it just as obvious that it "should" return "1foo" --
which can also be very useful.  In the absence of a compelling
non-exceptional sense, Python refuses to guess:  you have to explicitly name
the sense you intended, and then your intent is clear for all to see.  After
all, Python is a programming language, not a psychic hotline <0.9 wink>.  In
the other examples you gave, such as 1+1j, returning a complex result is
wholly unsurprising to anyone.  I suppose you may want 1+"1j" to return 2,
though ...

if-so-python's-not-your-language-ly y'rs  - tim






More information about the Python-list mailing list