[Python-Dev] PEP 204 - Range Literals

Paul Prescod paul@prescod.net
Wed, 19 Jul 2000 11:11:39 -0500


    Should range literals create a list of the passed-in type ? It
    might be desirable in the cases of other builtin types, such as
    longs and strings:
    
    >>> [ 1L : 2L<<64 : 2<<32L ]    
    >>> ["a":"z":"b"]
    >>> ["a":"z":2]
    
    However, this might be too much `magic' to be obvious.  

Well the step argument is of debatable utility for strings but ["0":"9"]
seems mildly useful. Also, it makes sense to create a range of floating
point numbers.

If we were going to do this, we would probably have an overloadable
operator: 

string.__range__( start=None, end=None, step=None )

It could return a sequence of whatever kind.

I'm not clear why we can't implement it as a function call to
__builtins__.range .

-- 
 Paul Prescod - Not encumbered by corporate consensus
Just how compassionate can a Republican get before he has to leave the 
GOP and join Vegans for Global Justice? ... One moment, George W. Bush
is holding a get-to-know-you meeting with a bunch of gay Republicans.
The next he is holding forth on education or the environment ... It is
enough to make a red-blooded conservative choke on his spotted-owl
drumstick.     - April 29th, Economist