CyclicTuple¶
-
class
abjad.utilities.CyclicTuple.
CyclicTuple
(items=None)¶ Cyclic tuple.
Initializes from string:
>>> tuple_ = abjad.CyclicTuple('abcd')
>>> tuple_ CyclicTuple(['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
__contains__
Is true when cyclic tuple contains item
.__eq__
Is true when argument
is a tuple with items equal to those of this cyclic tuple.__getitem__
Gets item or slice identified by argument
.__hash__
Hashes cyclic tuple. __iter__
Iterates cyclic tuple. __len__
Gets length of cyclic tuple. __str__
Gets string representation of cyclic tuple. items
Gets items in cyclic tuple. Special methods
-
__eq__
(argument)¶ Is true when
argument
is a tuple with items equal to those of this cyclic tuple.Return type: bool
-
(
AbjadObject
).__format__
(format_specification='')¶ Formats Abjad object.
Set
format_specification
to''
or'storage'
. Interprets''
equal to'storage'
.Returns string.
-
__getitem__
(argument)¶ 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: Any
-
__iter__
()¶ Iterates cyclic tuple.
Iterates items only once.
Does not iterate infinitely.
Return type: Iterator
[+T_co]
-
(
AbjadObject
).__repr__
()¶ Gets interpreter representation of Abjad object.
Returns string.
-
__str__
()¶ Gets string representation of cyclic tuple.
Gets string:
>>> str(abjad.CyclicTuple('abcd')) '(a, b, c, d)'
Gets string:
>>> str(abjad.CyclicTuple([1, 2, 3, 4])) '(1, 2, 3, 4)'
Return type: str
Read-only properties
-
items
¶ Gets items in cyclic tuple.
Gets items:
>>> tuple_ = abjad.CyclicTuple('abcd') >>> tuple_.items ('a', 'b', 'c', 'd')
Gets items:
>>> tuple_ = abjad.CyclicTuple([1, 2, 3, 4]) >>> tuple_.items (1, 2, 3, 4)
Return type: Tuple
-