2021-08-16 09:07:46 -04:00
|
|
|
:mod:`builtins` -- builtin functions and exceptions
|
|
|
|
===================================================
|
2016-06-08 17:24:52 -04:00
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
All builtin functions and exceptions are described here. They are also
|
|
|
|
available via ``builtins`` module.
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
For more information about built-ins, see the following CPython documentation:
|
|
|
|
|
|
|
|
* `Builtin CPython Functions <https://docs.python.org/3/library/functions.html>`_
|
|
|
|
* `Builtin CPython Exceptions <https://docs.python.org/3/library/exceptions.html>`_
|
|
|
|
* `Builtin CPython Constants <https://docs.python.org/3/library/constants.html>`_
|
|
|
|
|
|
|
|
.. note:: Not all of these functions, types, exceptions, and constants are turned
|
|
|
|
on in all CircuitPython ports, for space reasons.
|
|
|
|
|
2017-07-01 15:20:49 -04:00
|
|
|
Functions and types
|
|
|
|
-------------------
|
2016-06-08 17:24:52 -04:00
|
|
|
|
|
|
|
.. function:: abs()
|
|
|
|
|
|
|
|
.. function:: all()
|
|
|
|
|
|
|
|
.. function:: any()
|
|
|
|
|
|
|
|
.. function:: bin()
|
|
|
|
|
|
|
|
.. class:: bool()
|
|
|
|
|
|
|
|
.. class:: bytearray()
|
|
|
|
|
|
|
|
.. class:: bytes()
|
|
|
|
|
2018-02-20 20:34:59 -05:00
|
|
|
|see_cpython| `bytes`.
|
2017-07-02 08:37:31 -04:00
|
|
|
|
2016-06-08 17:24:52 -04:00
|
|
|
.. function:: callable()
|
|
|
|
|
|
|
|
.. function:: chr()
|
|
|
|
|
|
|
|
.. function:: classmethod()
|
|
|
|
|
|
|
|
.. function:: compile()
|
|
|
|
|
|
|
|
.. class:: complex()
|
|
|
|
|
2016-10-24 20:02:47 -04:00
|
|
|
.. function:: delattr(obj, name)
|
|
|
|
|
|
|
|
The argument *name* should be a string, and this function deletes the named
|
|
|
|
attribute from the object given by *obj*.
|
|
|
|
|
2016-06-08 17:24:52 -04:00
|
|
|
.. class:: dict()
|
|
|
|
|
|
|
|
.. function:: dir()
|
|
|
|
|
|
|
|
.. function:: divmod()
|
|
|
|
|
|
|
|
.. function:: enumerate()
|
|
|
|
|
|
|
|
.. function:: eval()
|
|
|
|
|
|
|
|
.. function:: exec()
|
|
|
|
|
|
|
|
.. function:: filter()
|
|
|
|
|
|
|
|
.. class:: float()
|
|
|
|
|
|
|
|
.. class:: frozenset()
|
|
|
|
|
2018-05-23 15:07:32 -04:00
|
|
|
`frozenset()` is not enabled on non-Express CircuitPython boards.
|
2018-05-22 19:52:01 -04:00
|
|
|
|
2016-06-08 17:24:52 -04:00
|
|
|
.. function:: getattr()
|
|
|
|
|
|
|
|
.. function:: globals()
|
|
|
|
|
|
|
|
.. function:: hasattr()
|
|
|
|
|
|
|
|
.. function:: hash()
|
|
|
|
|
|
|
|
.. function:: hex()
|
|
|
|
|
|
|
|
.. function:: id()
|
|
|
|
|
|
|
|
.. function:: input()
|
|
|
|
|
|
|
|
.. class:: int()
|
|
|
|
|
2017-04-08 17:06:54 -04:00
|
|
|
.. classmethod:: from_bytes(bytes, byteorder)
|
|
|
|
|
2019-01-13 23:51:13 -05:00
|
|
|
In CircuitPython, ``byteorder`` parameter must be positional (this is
|
2017-04-08 17:06:54 -04:00
|
|
|
compatible with CPython).
|
|
|
|
|
|
|
|
.. method:: to_bytes(size, byteorder)
|
|
|
|
|
2019-01-13 23:51:13 -05:00
|
|
|
In CircuitPython, ``byteorder`` parameter must be positional (this is
|
2017-04-08 17:06:54 -04:00
|
|
|
compatible with CPython).
|
|
|
|
|
2016-06-08 17:24:52 -04:00
|
|
|
.. function:: isinstance()
|
|
|
|
|
|
|
|
.. function:: issubclass()
|
|
|
|
|
|
|
|
.. function:: iter()
|
|
|
|
|
|
|
|
.. function:: len()
|
|
|
|
|
|
|
|
.. class:: list()
|
|
|
|
|
|
|
|
.. function:: locals()
|
|
|
|
|
|
|
|
.. function:: map()
|
|
|
|
|
|
|
|
.. function:: max()
|
|
|
|
|
|
|
|
.. class:: memoryview()
|
|
|
|
|
|
|
|
.. function:: min()
|
|
|
|
|
|
|
|
.. function:: next()
|
|
|
|
|
|
|
|
.. class:: object()
|
|
|
|
|
|
|
|
.. function:: oct()
|
|
|
|
|
|
|
|
.. function:: open()
|
|
|
|
|
|
|
|
.. function:: ord()
|
|
|
|
|
|
|
|
.. function:: pow()
|
|
|
|
|
|
|
|
.. function:: print()
|
|
|
|
|
|
|
|
.. function:: property()
|
|
|
|
|
|
|
|
.. function:: range()
|
|
|
|
|
|
|
|
.. function:: repr()
|
|
|
|
|
|
|
|
.. function:: reversed()
|
|
|
|
|
2018-05-23 15:07:32 -04:00
|
|
|
`reversed()` is not enabled on non-Express CircuitPython boards.
|
2018-05-22 19:52:01 -04:00
|
|
|
|
2016-06-08 17:24:52 -04:00
|
|
|
.. function:: round()
|
|
|
|
|
|
|
|
.. class:: set()
|
|
|
|
|
|
|
|
.. function:: setattr()
|
|
|
|
|
2016-10-24 20:02:47 -04:00
|
|
|
.. class:: slice()
|
|
|
|
|
|
|
|
The *slice* builtin is the type that slice objects have.
|
|
|
|
|
2016-06-08 17:24:52 -04:00
|
|
|
.. function:: sorted()
|
|
|
|
|
|
|
|
.. function:: staticmethod()
|
|
|
|
|
|
|
|
.. class:: str()
|
|
|
|
|
|
|
|
.. function:: sum()
|
|
|
|
|
|
|
|
.. function:: super()
|
|
|
|
|
|
|
|
.. class:: tuple()
|
|
|
|
|
|
|
|
.. function:: type()
|
|
|
|
|
|
|
|
.. function:: zip()
|
2017-06-24 16:45:38 -04:00
|
|
|
|
|
|
|
|
|
|
|
Exceptions
|
|
|
|
----------
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: ArithmeticError
|
|
|
|
|
2017-07-01 15:20:49 -04:00
|
|
|
.. exception:: AssertionError
|
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: AttributeError
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: BaseException
|
|
|
|
|
|
|
|
.. exception:: BrokenPipeError
|
|
|
|
|
|
|
|
.. exception:: ConnectionError
|
|
|
|
|
|
|
|
.. exception:: EOFError
|
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: Exception
|
|
|
|
|
|
|
|
.. exception:: ImportError
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: IndentationError
|
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: IndexError
|
|
|
|
|
|
|
|
.. exception:: KeyboardInterrupt
|
|
|
|
|
|
|
|
.. exception:: KeyError
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: LookupError
|
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: MemoryError
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: MpyError
|
|
|
|
|
|
|
|
Not a part of the CPython standard library
|
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: NameError
|
|
|
|
|
|
|
|
.. exception:: NotImplementedError
|
|
|
|
|
|
|
|
.. exception:: OSError
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: OverflowError
|
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: RuntimeError
|
|
|
|
|
2018-05-14 16:57:50 -04:00
|
|
|
.. exception:: ReloadException
|
|
|
|
|
|
|
|
`ReloadException` is used internally to deal with soft restarts.
|
2022-05-13 12:03:14 -04:00
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
Not a part of the CPython standard library
|
|
|
|
|
|
|
|
.. exception:: StopAsyncIteration
|
2018-05-14 16:57:50 -04:00
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: StopIteration
|
|
|
|
|
2017-07-01 15:20:49 -04:00
|
|
|
.. exception:: SyntaxError
|
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: SystemExit
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: TimeoutError
|
2017-07-02 08:37:31 -04:00
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: TypeError
|
|
|
|
|
2022-05-12 13:05:27 -04:00
|
|
|
.. exception:: UnicodeError
|
2017-07-02 08:37:31 -04:00
|
|
|
|
2017-06-24 16:45:38 -04:00
|
|
|
.. exception:: ValueError
|
2017-07-01 15:20:49 -04:00
|
|
|
|
|
|
|
.. exception:: ZeroDivisionError
|
2022-05-12 13:05:27 -04:00
|
|
|
|
|
|
|
Constants
|
|
|
|
---------
|
|
|
|
|
|
|
|
.. data:: Ellipsis
|
|
|
|
|
|
|
|
.. data:: NotImplemented
|