mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-07-27 19:57:02 +00:00
This merges the useful information from two different places: - The original docstring for const. - Writing MicroPython code for constrained devices. Also reduce type to just int, because only ints are supported.
14 lines
380 B
Python
14 lines
380 B
Python
from micropython import const
|
|
|
|
# This value can be used here. Other files can import it too.
|
|
APPLES = const(123)
|
|
|
|
# These values can only be used within this file.
|
|
_ORANGES = const(1 << 8)
|
|
_BANANAS = const(789 + _ORANGES)
|
|
|
|
# You can read the constants as normal values. The compiler
|
|
# will just insert the numeric values for you.
|
|
fruit = APPLES + _ORANGES + _BANANAS
|
|
print(fruit)
|