cyclictuple

digraph InheritanceGraph { graph [bgcolor=transparent, color=lightsteelblue2, fontname=Arial, fontsize=10, outputorder=edgesfirst, overlap=prism, penwidth=2, rankdir=LR, splines=spline, style="dashed, rounded", truecolor=true]; node [colorscheme=pastel19, fontname=Arial, fontsize=10, height=0, penwidth=2, shape=box, style="filled, rounded", width=0]; edge [color=lightslategrey, penwidth=1]; subgraph "cluster_abjad.cyclictuple" { graph [label="abjad.cyclictuple"]; node [color=1]; "abjad.cyclictuple.CyclicTuple" [URL="../api/abjad/cyclictuple.html#abjad.cyclictuple.CyclicTuple", color=black, fontcolor=white, label="Cyclic\nTuple", target=_top]; } subgraph cluster_builtins { graph [label=builtins]; node [color=2]; "builtins.object" [URL="https://docs.python.org/3.10/library/functions.html#object", label=object, target=_top]; } "builtins.object" -> "abjad.cyclictuple.CyclicTuple"; }


Classes

CyclicTuple

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

__contains__

Is true when cyclic tuple contains item.

__eq__

Compares items.

__getitem__

Gets item or slice identified by argument.

__hash__

Return hash(self).

__iter__

Iterates cyclic tuple.

__len__

Gets length of cyclic tuple.

__post_init__

__repr__

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:

bool

overridden __eq__(argument)[source]

Compares items.

Return type:

bool

__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:

Any

overridden __hash__()

Return hash(self).

__iter__()[source]

Iterates cyclic tuple.

Iterates items only once.

Does not iterate infinitely.

Return type:

Iterator

__len__()[source]

Gets length of cyclic tuple.

Return type:

int

__post_init__()[source]
overridden __repr__()

Return repr(self).