cyclictuple¶
Classes
Cyclic tuple. |
- class abjad.cyclictuple.CyclicTuple(items=())[source]¶
Cyclic tuple.
Initializes from string:
>>> tuple_ = abjad.CyclicTuple("abcd")
>>> tuple_ CyclicTuple(items=('a', 'b', 'c', 'd'))
>>> for x in range(8): ... print(x, tuple_[x]) ... 0 a 1 b 2 c 3 d 4 a 5 b 6 c 7 d
Cyclic tuples overload the item-getting method of built-in tuples.
Cyclic tuples return a value for any integer index.
Cyclic tuples otherwise behave exactly like built-in tuples.
Attributes Summary
Is true when cyclic tuple contains
item
.Compares
items
.Gets item or slice identified by
argument
.Return hash(self).
Iterates cyclic tuple.
Gets length of cyclic tuple.
Return repr(self).
Special methods
- __contains__(item)[source]¶
Is true when cyclic tuple contains
item
.>>> tuple_ = abjad.CyclicTuple("abcd") >>> "a" in tuple_ True
- Return type:
- __getitem__(argument)[source]¶
Gets item or slice identified by
argument
.Gets slice open at right:
>>> items = [0, 1, 2, 3, 4, 5] >>> tuple_ = abjad.CyclicTuple(items=items) >>> tuple_[2:] (2, 3, 4, 5)
Gets slice closed at right:
>>> items = [0, 1, 2, 3, 4, 5] >>> tuple_ = abjad.CyclicTuple(items=items) >>> tuple_[:15] (0, 1, 2, 3, 4, 5, 0, 1, 2, 3, 4, 5, 0, 1, 2)
Raises index error when
argument
can not be found in cyclic tuple.- Return type:
- overridden __hash__()¶
Return hash(self).
- __iter__()[source]¶
Iterates cyclic tuple.
Iterates items only once.
Does not iterate infinitely.
- Return type:
- overridden __repr__()¶
Return repr(self).