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

Steven D. Majewski sdm7g at Virginia.EDU
Fri Nov 9 17:01:25 CET 2001


On Fri, 9 Nov 2001, Rainer Deyke wrote:

> "Steven D. Majewski" <sdm7g at minsky.med.virginia.edu> wrote in message
> news:mailman.1005260651.24404.python-list at python.org...
> > If "for i in 10:" was legal, I'ld guess it meant the same thing as
> > "for i in [10]:" or "for i in (10,):"
> 
> Guessing is no substitute for reading the docs, even in Python.

Principle of Least Surprise. You can hang any meaning on any sequence
of tokens, but some of them are likely to cause confusion.  

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

	
-- Steve






More information about the Python-list mailing list