mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 17:14:41 +00:00
ubuiltins: Add bytearray.
This commit is contained in:
@@ -7,6 +7,8 @@ Classes and types
|
||||
|
||||
.. autoclass:: ubuiltins.bool
|
||||
|
||||
.. autoclass:: ubuiltins.bytearray
|
||||
|
||||
.. autoclass:: ubuiltins.bytes
|
||||
|
||||
.. autoclass:: ubuiltins.complex
|
||||
|
||||
@@ -42,6 +42,7 @@ import usys
|
||||
# These get overridden later on, but we still want to use the originals
|
||||
# for the purpose of typing the doc strings.
|
||||
_bool = bool
|
||||
_bytearray = bytearray
|
||||
_bytes = bytes
|
||||
_callable = callable
|
||||
_complex = complex
|
||||
@@ -143,6 +144,33 @@ class bytes:
|
||||
"""
|
||||
|
||||
|
||||
class bytearray:
|
||||
@overload
|
||||
def __init__(self) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, source: _int) -> None:
|
||||
...
|
||||
|
||||
@overload
|
||||
def __init__(self, source: Union[_bytes, _bytearray, _str, Iterable[_int]]) -> None:
|
||||
...
|
||||
|
||||
def __init__(self, *args):
|
||||
"""
|
||||
Creates a new ``bytearray`` object, which is a sequence of integers
|
||||
in the range ``0 <= x <= 255``. This object is mutable, which means
|
||||
that you can change its contents after you create it.
|
||||
|
||||
* If no argument is given, this creates an empty ``bytearray``.
|
||||
* If the ``source`` argument is an integer, this creates a ``bytearray``
|
||||
of zeros. The argument specifies how many zeros.
|
||||
* For all other valid ``source`` arguments, this creates a bytearray with
|
||||
the same byte sequence as the given ``source`` argument.
|
||||
"""
|
||||
|
||||
|
||||
def callable(object: Any) -> _bool:
|
||||
"""
|
||||
Returns ``True`` if the object argument appears callable, ``False`` if not.
|
||||
|
||||
Reference in New Issue
Block a user