Python complaints
Fredrik Lundh
fredrik at pythonware.com
Wed Nov 24 09:06:03 EST 1999
Markus Stenberg <mstenber at cc.Helsinki.FI> wrote:
> > - a less yucky way of saying "for i in range(1,20,3)"
>
> see above - although some special syntactic sugar would be "nice", I prefer
> minimalistic approach over say, C.. of course, Dylan does it (IMNSHO)
> cleanest:
>
> for (i from 3 to 19 by 3)
> ...
note that python already has a special syntax
for this purpose:
>>> a = range(20)
>>> print a[1:20:3]
Traceback (innermost last):
File "<stdin>", line 1, in ?
TypeError: sequence index must be integer
(note that you got a type error, not a syntax
error. numpy arrays fully support this syntax).
in other words, you don't have to be guido to
realize that something like:
for i in [1:20:3]:
...
could be the right way to do it in Python. in
fact, it's already on the list for 2.0:
http://www.foretec.com/python/workshops/1998-11/proceedings/guido/sld011.htm
</F>
More information about the Python-list
mailing list