PEP 284, Integer for-loops (code bash?)

Gustavo Cordova gcordova at hebmex.com
Thu Mar 7 17:36:08 EST 2002


> 
> On Thu, 07 Mar 2002 13:47:49 -0800, David Eppstein <eppstein at ics.uci.edu>
> wrote:
> > But there are a few warts in the design, where instead of 
> > just using Python I have to stop and explain some unnatural
> > unintuitive syntax.
> 
> You keep using that word.  I do not think it means what 
> you think it means.
> 
>     You killed my language, prepare to die!
> 
> </Inigo Montoya>
> 

Or, you could propose an excersize for your students, like:

"Make a module which will create a helper object, to make
prettier loop sequences."

And propose a notation, like:

>>> for ix in Ints[0, ...]:
...   do_something(ix)

will loop from zero onward, one by one; and:

>>> for ix in Ints[0, 3, ...]:
...   do_something(ix)

will loop from zero onward, three-by-three; and:

>>> for ix in Ints[0, ..., 10]:
...   do_something(ix)

will loop from zero up to (including) 10; and...

>>> for ix in Ints[0, 3, ..., 10]:
...   do_something(ix)

will do the obvious.


So, I propose an answer to this, and here it is.

Just do a "from ints import Ints" at the beginning of the program.

Have a nice evening :-)

-gustavo

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ints.py
Type: application/octet-stream
Size: 2521 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20020307/55a17359/attachment.obj>


More information about the Python-list mailing list