DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

An Interval Mapping Class

02.15.2006
| 2344 views |
  • submit to reddit
        A kind of dictionary which allows you to map data intervals to values.
Download 'intervalmap' from this <a href=http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/457411>recipe page</a>.
>>> i = intervalmap()
>>> i[0:5] = '0-5'
>>> i[8:12] = '8-12'
>>> print i[2]
0-5
>>> print i[10]
8-12
>>>