iters on ints? (reducing the need for range/xrange)

Rainer Deyke root at rainerdeyke.com
Fri Nov 9 15:53:18 EST 2001


"Steven D. Majewski" <sdm7g at Virginia.EDU> wrote in message
news:mailman.1005321732.23772.python-list at python.org...
> Currently, trailing commas are optionally allowed on all tuples
> except singleton's where they are required. (That in itself is a
> confusing syntactical wart that I'ld like to use the time machine
> to remove! ). Don't you think that the extremely different behaviour
> of the last of these compared to the others could be a needless
> cause of confusion?
>
> for i in 3,2,1: print i
>
> for i in 3,2,: print i
>
> for i in 3,2: print i
>
> for i in 3,: print i
>
> for i in 3: print i

for i in [3],[2],[1]: print i
for i in [3],[2],: print i
for i in [3],[2]: print i
for i in [3],: print i
for i in [3]: print i

If this causes confusion, then it's good to have, because then people can
move beyond confusion toward understanding.  An unadorned expression 'e' is
not treated as the single element tuple '(e,)' anywhere else in the
language.  The principle of least surprise says that integers shouldn't get
special treatment in this case.


--
Rainer Deyke (root at rainerdeyke.com)
Shareware computer games           -           http://rainerdeyke.com
"In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor





More information about the Python-list mailing list