Author daniel.urban
Recipients daniel.urban, eric.araujo, stutzbach
Date 2010-07-21.20:25:19
SpamBayes Score 0.0372697
Marked as misclassified No
Message-id <1279743921.92.0.0185074026278.issue9213@psf.upfronthosting.co.za>
In-reply-to
Content
The attached patch adds the range.count and range.index methods.
Pseudocode for the two method:

def count(self, ob):
    if ob in self:
        return 1
    else:
        return 0

def index(self, ob, start=0, stop=len(self)):
    if ob in self:
        idx = (ob - self.start) // self.step
        if start < 0:
            start = start + len(self)
        if stop < 0:
            stop = stop + len(self)
        if start <= idx < stop:
            return idx
    raise ValueError("{!r} is not in range".format(ob))
History
Date User Action Args
2010-07-21 20:25:22daniel.urbansetrecipients: + daniel.urban, stutzbach, eric.araujo
2010-07-21 20:25:21daniel.urbansetmessageid: <1279743921.92.0.0185074026278.issue9213@psf.upfronthosting.co.za>
2010-07-21 20:25:20daniel.urbanlinkissue9213 messages
2010-07-21 20:25:20daniel.urbancreate