Make a tuple with cyclic indices. Subclass tuple to make a new class cyclictuple (see Chapter…

Make a tuple with cyclic indices.

Subclass tuple to make a new class cyclictuple (see Chapter
8.6.12) which allows the tuple index to take on any integer value. When an
index is out of bounds we just count from the beginning again, thus making the
index cyclic. Here is a session:

>>> t = cyclictuple((1,2,3))

>>> t[3]

1

>>> t[9]

1

>>> t[10]

2

>>> t[-3]

1

>>> t[-31]

3