"Antoon Pardon" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On 2006-09-27, Peter Otten <[EMAIL PROTECTED]> wrote:
>> Antoon Pardon wrote:
>>
>>> 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
>>>
<snip>

What about this?

-- Paul


class TopClass(int):
    def __add__(self,other):
        return self
    def __sub__(self,other):
        return self
    def __mul__(self,other):
        return self
    def __div__(self,other):
        return self
    def __iadd__(self,other):
        return self
    def __isub__(self,other):
        return self
    def __imul__(self,other):
        return self
    def __idiv__(self,other):
        return self
    def __str__(self):
        return "Top"

import sys
Top = TopClass(sys.maxint)

print Top
print int(Top)
print int(Top-1e9)

a = range(10)
print a[:Top]
print a[Top:]
print a[3:Top]


Prints:
Top
2147483647
2147483647
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[]
[3, 4, 5, 6, 7, 8, 9] 


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to