Tuples -- who needs 'em
Glenn Andreas
gandreas at delver._REMOVE_TO_REPLY_.com
Fri Apr 7 11:57:30 EDT 2000
In article <38ED8EF2.B0835BE1 at acm.org>, "Robert W. Cunningham"
<rcunning at acm.org> wrote:
> Greg Ewing wrote:
>
> > Unfortunately, Python *does* need 1-tuples. If
> > only ASCII had more kinds of brackets, Guido might
> > have chosen differently. Maybe if Python 3000 uses
> > Unicode for source files...
>
> Well, if they can be syntactically disambiguated from Python relational
> comparison operators, "<" and ">" can be used as "brokets".
>
Funny, I was thinking the exact same thing. Other than needing some
extra spaces, it should work (after all, C++ uses them as well).
However, depending on the details of the parser (and it's been way too
long since I've brushed up on parser technology), you might have
problems with:
x = < a, a > b > # (a,a>b) in old syntax
At the very least, this visually is jarring and you need to mentally
"reparse" when you get to the second ">". Another alternative is to
switch to multi-character brackets, perhaps:
x = (* a, b *)
or:
x = <| a, b |>
With two characters, there could be hundreds of possible "bracket"
pairs. Unfortunately, that makes your code look like it has been
infested with "smileys". I seem to remember that some other languages
using them though (besides old Pascal style comments, that is).
More information about the Python-list
mailing list