Top and Bottom Values [PEP: 326]

Antoon Pardon apardon at forel.vub.ac.be
Wed Sep 27 02:47:26 EDT 2006


I know this PEP is rejected. However I have a problem that 
would benefit from having extreme values and the sample
implementation that is given in the PEP is unsatifactory
for my purpose.

I had written my own module, which works similarly but
is somewhat extended. Here is an example of how it can
be used and how I would like to use it but get stuck.

from extreme import Top
>>> Top
Top
>>> Top + 1
Top
>>> Top - 30
Top
>>> Top > 1e99
True
>>> lst = range(10)
>>> lst[:Top]
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: slice indices must be integers or None

So this is where I am stuck. I need this Top value in
a context where it can be used as a start or stop value
in a slice. My idea was that since a stop value greater
than the length of lst in this context would simply return
a copy of lst, using Top in such a way should behave so
too. However I don't see a way of doing that.

So can someone provide ideas to get this behaviour?
If not is there a chance that PEP 326 gets revived?

-- 
Antoon Pardon



More information about the Python-list mailing list