@@ -27,3 +27,55 @@ Classes
27
27
28
28
Append new elements as contained in *iterable * to the end of
29
29
array, growing it.
30
+
31
+ .. method :: __getitem__(index)
32
+
33
+ Indexed read of the array, called as ``a[index] `` (where ``a `` is an ``array ``).
34
+ Returns a value if *index * is an ``int `` and an ``array `` if *index * is a slice.
35
+ Negative indices count from the end and ``IndexError `` is thrown if the index is
36
+ out of range.
37
+
38
+ **Note: ** ``__getitem__ `` cannot be called directly (``a.__getitem__(index) `` fails) and
39
+ is not present in ``__dict__ ``, however ``a[index] `` does work.
40
+
41
+ .. method :: __setitem__(index, value)
42
+
43
+ Indexed write into the array, called as ``a[index] = value `` (where ``a `` is an ``array ``).
44
+ ``value `` is a single value if *index * is an ``int `` and an ``array `` if *index * is a slice.
45
+ Negative indices count from the end and ``IndexError `` is thrown if the index is out of range.
46
+
47
+ **Note: ** ``__setitem__ `` cannot be called directly (``a.__setitem__(index, value) `` fails) and
48
+ is not present in ``__dict__ ``, however ``a[index] = value `` does work.
49
+
50
+ .. method :: __len__()
51
+
52
+ Returns the number of items in the array, called as ``len(a) `` (where ``a `` is an ``array ``).
53
+
54
+ **Note: ** ``__len__ `` cannot be called directly (``a.__len__() `` fails) and the
55
+ method is not present in ``__dict__ ``, however ``len(a) `` does work.
56
+
57
+ .. method :: __add__(other)
58
+
59
+ Return a new ``array `` that is the concatenation of the array with *other *, called as
60
+ ``a + other `` (where ``a `` and *other * are both ``arrays ``).
61
+
62
+ **Note: ** ``__add__ `` cannot be called directly (``a.__add__(other) `` fails) and
63
+ is not present in ``__dict__ ``, however ``a + other `` does work.
64
+
65
+ .. method :: __iadd__(other)
66
+
67
+ Concatenates the array with *other * in-place, called as ``a += other `` (where ``a `` and *other *
68
+ are both ``arrays ``). Equivalent to ``extend(other) ``.
69
+
70
+ **Note: ** ``__iadd__ `` cannot be called directly (``a.__iadd__(other) `` fails) and
71
+ is not present in ``__dict__ ``, however ``a += other `` does work.
72
+
73
+ .. method :: __repr__()
74
+
75
+ Returns the string representation of the array, called as ``str(a) `` or ``repr(a)` ``
76
+ (where ``a `` is an ``array ``). Returns the string ``"array(<type>, [<elements>])" ``,
77
+ where ``<type> `` is the type code letter for the array and ``<elements> `` is a comma
78
+ seperated list of the elements of the array.
79
+
80
+ **Note: ** ``__repr__ `` cannot be called directly (``a.__repr__() `` fails) and
81
+ is not present in ``__dict__ ``, however ``str(a) `` and ``repr(a) `` both work.
0 commit comments