f---ing typechecking

Marc marc at penninga.info
Thu Feb 15 10:10:52 EST 2007


On 15 feb, 07:21, James Stroud <jstr... at mbi.ucla.edu> wrote:
> I guess we differ on what is obvious. This seems obvious to me:
>
> [1] + (1,) => [1, 1]
> (1,) + [1] => (1, 1)
>
> simply becuase the operand on the left should take precendence because
> its "__add__" is called and its "__add__" returns a list. In essence, as
> we know the obviously correct behavior for __add__ and __radd__, then it
> would be the obviously correct behavior that the above would follow.

Given those obviouses, the following seems to me:

[1] + (1,) => [1, (1,)]

That's the trouble with obvious -- my obvious may not be so obvious to
you (and vice versa). That's why the Zen of Python says "In the face
of ambiguity, refuse the temptation to guess." (Although it also says
"Flat is better than nested", but I'll ignore that for now.)

Basically -- if you want Perl, you know where to find it ;-)

Marc




More information about the Python-list mailing list