Any other Python flaws?

Martijn Faassen m.faassen at vet.uu.nl
Wed Jun 20 18:33:37 EDT 2001


Carsten Geckeler <geckeler at gmx.net> wrote:
> On 18 Jun 2001, Martijn Faassen wrote:

>> Carsten Geckeler <uioziaremwpl at spammotel.com> wrote:
>> > On 14 Jun 2001, Martijn Faassen wrote:
>> Sure, so ( and ) is mandatory. :) I know it's due to operator
>> precendence issues. Doesn't mean it's not something that doesn't bite
>> people. The actually really weird case is the single element tuple,
>> which you can instead write as '% foo'.

> Are you annoyed that Python provides this simplification?  Surely not.

No. I'm not actually annoyed by most of these issues; they're not
big enough. They're just things that in some ideal world could possibly
be better. :)

>> But since single element tuples are a wart by themselves, this extra
>> magic is necessary. Perhaps a language is possible where single
>> element tuples actually are single elements, though that may introduce
>> other warts.

> So that's your point.

Not the only point. I still think I have a point that the mandatory
() around a tuple in that place are a wart. I'd have liked it to
be different but that would mean a change in Python's precendence rules
that would probably cause other annoyances. 

> But then propose another way of making one-element
> tuples.  BTW, I don't see "(1,)" as magic, more as simple given syntax.

I see the single element syntax as 'magical syntax', just like:

print "foo",

is magical syntax. It's just syntax that isn't very pretty as everwhere
else the comma implies there either is another element coming or that if it's
the last element, the comma is ignored.

'magic' (here Martijn defines magic) is where something suddenly behaves
different in a way that's outside of an easy to predict pattern that
holds elsewhere. It's where hard to detect subtleties can have uncommonly
large effects. Where the mind stumbles.

> Since the curly brackets {} are used for dictionaries, normal brackets []
> for lists, there are only the parenthesis () left.  And since they are
> used for grouping, this special case for one-element tuple is needed.
> Although I admit that I doesn't look very nice, I don't see any
> alternatives.

And the parenthesis aren't even necessary for tuples, which is nice in
some circumstances. But in an ideal world there would be another type of
brackets on my keyboard. :)

Regards,

Martijn 
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list