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

Tim Peters tim.one at comcast.net
Sat Mar 9 15:58:40 EST 2002


[Laura Creighton]
> ...
> 2. Haskell, which I mispelt, shame on me, I know better, is a
>    functional language.
>    ...
>    So, what I meant was 'I wish that Guido had used Haskell's syntax
>    for arithmetic sequences in Python's  for loops'.  That is as
>    follows:
>
>    [1..10]     => [1,2,3,4,5,6,7,8,9,10]
>    [1,3..8]    => [1,3,5,7]
>    [1,3..]     => [1,3,5,7,9, ... (infinite sequence)
>
>    This is not restricted to numbers, char works great.
>    ...
> I have probably forgotten something, somebody else can add it.

Easier to point than to retype:

    http://aspn.activestate.com/ASPN/Mail/Message/909806

Note a practical difficulty in adopting this to Python (beyond adding 4 new
method slots to every type that wants to participate):  the frequent Python
range(len(seq)) maps to Haskell [0 .. len(seq)-1], and that's begging for
off-by-1 errors in real life.  Saying that a Python version went "up to but
not including" the right endpoint would be an ugliness of a different sort.

> 3.  Make the time to learn Haskell.  It is simply too much fun.

Yes it is!  Haskell is the most Pythonic of all languages that have nothing
in common with Python.  Well, they do have one thing in common:  they both
drive Scheme True Believeers mad <wink>.

albeit-for-different-reasons-ly y'rs  - tim





More information about the Python-list mailing list