Commit 64db4080 authored by Paul Sokolovsky's avatar Paul Sokolovsky
Browse files

docs/library/index: Elaborate on u-modules.

Also, remove an "only" directive in u-modules description.
parent 30bca45e
...@@ -36,15 +36,20 @@ Python standard libraries and micro-libraries ...@@ -36,15 +36,20 @@ Python standard libraries and micro-libraries
The following standard Python libraries have been "micro-ified" to fit in with The following standard Python libraries have been "micro-ified" to fit in with
the philosophy of MicroPython. They provide the core functionality of that the philosophy of MicroPython. They provide the core functionality of that
module and are intended to be a drop-in replacement for the standard Python module and are intended to be a drop-in replacement for the standard Python
library. library. Some modules below use a standard Python name, but prefixed with "u",
e.g. ``ujson`` instead of ``json``. This is to signify that such a module is
.. only:: not port_unix micro-library, i.e. implements only a subset of CPython module functionality.
By naming them differently, a user has a choice to write a Python-level module
The modules are available by their u-name, and also by their non-u-name. The to extend functionality for better compatibility with CPython (indeed, this is
non-u-name can be overridden by a file of that name in your package path. what done by micropython-lib project mentioned above).
For example, ``import json`` will first search for a file ``json.py`` or
directory ``json`` and load that package if it is found. If nothing is found, On some embedded platforms, where it may be cumbersome to add Python-level
it will fallback to loading the built-in ``ujson`` module. wrapper modules to achieve naming compatibility with CPython, micro-modules
are available both by their u-name, and also by their non-u-name. The
non-u-name can be overridden by a file of that name in your package path.
For example, ``import json`` will first search for a file ``json.py`` or
directory ``json`` and load that package if it is found. If nothing is found,
it will fallback to loading the built-in ``ujson`` module.
.. only:: port_unix .. only:: port_unix
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment