Why I think range is a wart.
daniel.dittmar at sap.com
Wed Mar 13 18:26:40 CET 2002
> It happens to me too, mostly when I'm using a sliding window
> type algorithm, that is, I need to look at two adjacent members
> of the list. You can't do this easily by iterating through the list;
> unrolling the first entry and the last entry are a pain.
> Is there a way of handling this nicely? Somehow I doubt it.
def __init__ (self, list):
self.list = list + [None] # assuming None is a suitable out of
def __getitem__ (self, index):
return self.list [index:index + 2]
for currentItem, nextItem in ListWindow (mylist):
More information about the Python-list