Files
Laurens Valk 4c00c3209b micropython.const: Improve docstring, add example.
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.
2021-07-14 14:48:59 +02:00

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)