Warning:

To protect the digital assets of creators and enhance system security and stability, the CyberBrick Multi-Function Core Board does not support firmware flashing with any third-party tools! If you need to restore the Multi-Function Core Board to its factory state, please wait for the official recovery tool to be released by CyberBrick. If you proceed to flash the firmware using third-party tools, the firmware of the Multi-Function Core Board will be permanently damaged and cannot be recovered. CyberBrick will not be responsible for any consequences resulting from such operations.

This documentation is adapted from the official MicroPython project. The CyberBrick team has extended the source code with custom interfaces and features to our hardware and application needs.

In addition to these enhancements, certain built-in MicroPython interfaces have been intentionally disabled to protect the system's integrity, and ensure the overall security and reliability of the device. This also facilitates content protection for creators' intellectual property, where applicable.

Portions of the content are derived from the official MicroPython documentation and have been included here under its open-source license to provide users with a consistent and enriched development experience tailored to the CyberBrick platform.

array – arrays of numeric data

This module implements a subset of the corresponding CPython module, as described below. For more information, refer to the original CPython documentation: array.

Supported format codes: b, B, h, H, i, I, l, L, q, Q, f, d (the latter 2 depending on the floating-point support).

Classes

class array.array(typecode[, iterable])

Create array with elements of given type. Initial contents of the array are given by iterable. If it is not provided, an empty array is created.

append(val)

Append new element val to the end of array, growing it.

extend(iterable)

Append new elements as contained in iterable to the end of array, growing it.

__getitem__(index)

Indexed read of the array, called as a[index] (where a is an array). Returns a value if index is an int and an array if index is a slice. Negative indices count from the end and IndexError is thrown if the index is out of range.

Note: __getitem__ cannot be called directly (a.__getitem__(index) fails) and is not present in __dict__, however a[index] does work.

__setitem__(index, value)

Indexed write into the array, called as a[index] = value (where a is an array). value is a single value if index is an int and an array if index is a slice. Negative indices count from the end and IndexError is thrown if the index is out of range.

Note: __setitem__ cannot be called directly (a.__setitem__(index, value) fails) and is not present in __dict__, however a[index] = value does work.

__len__()

Returns the number of items in the array, called as len(a) (where a is an array).

Note: __len__ cannot be called directly (a.__len__() fails) and the method is not present in __dict__, however len(a) does work.

__add__(other)

Return a new array that is the concatenation of the array with other, called as a + other (where a and other are both arrays).

Note: __add__ cannot be called directly (a.__add__(other) fails) and is not present in __dict__, however a + other does work.

__iadd__(other)

Concatenates the array with other in-place, called as a += other (where a and other are both arrays). Equivalent to extend(other).

Note: __iadd__ cannot be called directly (a.__iadd__(other) fails) and is not present in __dict__, however a += other does work.

__repr__()

Returns the string representation of the array, called as str(a) or repr(a)` (where a is an array). Returns the string "array(<type>, [<elements>])", where <type> is the type code letter for the array and <elements> is a comma separated list of the elements of the array.

Note: __repr__ cannot be called directly (a.__repr__() fails) and is not present in __dict__, however str(a) and repr(a) both work.