( 2.31.New operators: 'eq', 'ne', 'last', '..' ) ?

Stefan Schwarzer s.schwarzer at ndh.net
Mon Jan 24 20:03:17 EST 2000


Hi Gerrit,

Gerrit Holl schrieb:
> > Perhaps the ".." operator is something to consider (if it isn't
> > incompatible with somethings else in the language), but most of
> > the times "range" does it's job very well.
> 
> Unfortunately, not yet. It's quite hard to get a string which
> would be a..k in Perl. Maybe a nice feature for range()?

I think, for consistency, range should return a list, not a string.
So 'a'..'d' should yield [ 'a', 'b', 'c', 'd' ], not 'abcd'.
Additionally, a..d should _not_ yield [ 'a', 'b', 'c', 'd' ] IMHO;
I would expect this to evaluate the variables a and d and compute the
resulting range. Perl can do the other thing, because variables
contain $@% stuff ;-) .

> >>> string.join(map(lambda i: chr(i), range(ord('a'), ord('k'))), '')
> 'abcdefghij'
> 
> Doesn't look very well, does it?

Ok, that's true :-)  I needed it only for numbers so far and thought
of something else yet :)

Stefan



More information about the Python-list mailing list