This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Yclept.Nemo
Recipients Yclept.Nemo
Date 2012-06-29.16:37:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1340987823.51.0.113696334515.issue15224@psf.upfronthosting.co.za>
In-reply-to
Content
Python 3.3 expands the range class but I would find some additional methods useful:

min/max: provides O(1) time
__and__: provides intersection: Range(...) & Range(...)

examples:
intersection #1:
a=Range.Range(9,58,4)
b=Range.Range(15,69,6)
c=a&b
print(c)
Range(21, 69, 12)
list(c)
[21, 33, 45, 57]

intersection #2:
a=Range.Range(-75,-7,4)
b=Range.Range(-111, -26, 6)
c=a&b
print(c)
Range(-75, -15, 12)
list(c)
[-75, -63, -51, -39, -27]

intersection #3:
a=Range.Range(58,9,-4)
b=Range.Range(15,69,6)
c=a&b
print(c)
Range(0, 0, 1)
list(c)
[]

I've attached an example Range class implemented in python that includes the min, max, and __and__ functions. It should be useful because the intersection algorithm is complicated. Extending the range class was a requirement for a python 3.2 project and hopefully python 3.4 can benefit.
History
Date User Action Args
2012-06-29 16:37:03Yclept.Nemosetrecipients: + Yclept.Nemo
2012-06-29 16:37:03Yclept.Nemosetmessageid: <1340987823.51.0.113696334515.issue15224@psf.upfronthosting.co.za>
2012-06-29 16:37:02Yclept.Nemolinkissue15224 messages
2012-06-29 16:37:02Yclept.Nemocreate