allowing braces around suites

Alex Martelli aleaxit at
Sat Aug 28 18:05:23 CEST 2004

Grant Edwards <grante at> wrote:
> IMO, the only non-ugly, non-hack solution would be to have
> another set of delimters that are used as tuple-constructors so
> tha the syntax for a literal tuple, a literal list, and a
> literal dictionary are consistent.

I think that a hypothetical greenfield-designed language similar to
Python might do without literal tuples, lists, and dictionaries, just
like Python today does without literal sets (in 2.4 where they're a
built-in type).  It would make some constructs more verbose,
specifically using words instead of punctuation, but I think that,
overall, that is reasonably Pythonic.

list(a, b, c) instead of [a, b, c] would not be horribly heavy syntax, I
think.  You can already use list() instead of [] -- just as dict()
instead of {} -- and I think sometimes that's more readable, even having
both choices.  tuple would work like list.  dict isn't quite so obvious,
except where the keys are constant strings that happen to be identifiers
in which case, even today, dict(a=1,b=2,c=3) is fine.  But I'm sure fine
solutions could be identified, as, also, for the issue of how to
differentiate from list(x) meaning [x] and list(x) meaning the same as
[foo for foo in x] -- for example list(*x) would also mean the latter,
so maybe that's the solution for this.

I think 'commas makes tuples when the commas don't mean anything else'
should stay, though, because somedict[x, y] or a,b=b,a depend on that,
and I find them just too sweet to lose!-)

This of course is all pretty hypothetical, just like the idea of
introducing a new set of delimiters -- won't happen in Python, not even
in 3.0.  Just musing about some details of language design.


More information about the Python-list mailing list