Any other Python flaws?

Carsten Geckeler geckeler at
Wed Jun 20 00:47:49 CEST 2001

On 18 Jun 2001, Martijn Faassen wrote:

> Carsten Geckeler <uioziaremwpl at> wrote:
> > On 14 Jun 2001, Martijn Faassen wrote:
> [snip]
> >> This may be considered a minor quibble; the mandatory use of () in
> >> case of multiple arguments to the % string interpolation operator:
> >>
> >> "%s" % "foo"
> >>
> >> "%s %s" % "foo", "bar" # doesn't work right
> >>
> >> "%s %s" % ("foo", "bar")
> > This has nothing to do with "mandatory" or optional.  This is a question
> > of operator precedence.  The "%" operator has higher precedence as the ","
> > operator, so grouping with (..) is necessary.
> 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.

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

Cheers, Carsten
Carsten Geckeler:  geckeler at gmx dot net

More information about the Python-list mailing list