Antoon Pardon <[EMAIL PROTECTED]> writes:
> It is something worth investigating, but I'm not sure it
> will suite my purpose. You see I have a table module,
> a table is like a list except the base index doesn't need
> to be 0. So I could have a table that is indexable from
> sys.maxint - 3 to sys.maxint + 7. I'm not sure tbl[:Top]
> would do what it is supposed to do in those circumstances.

Top = object()

class Table(list):
   def __getitem__(self, n):
       get = super(Table, self).__getitem__
       if n is Top:
          return get(-1)
       return get(n - self.baseindex)

a=Table(range(9))
a.baseindex = 3

>>> print a[5], a[Top]
2 8

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

Reply via email to