Syntax
MicroPython implements Python 3. You write indentation, functions, classes, exceptions, generators, closures and async/await the same way. The gaps are in the library and in a few implementation limits, not in the look of the language.
What you can rely on
- Integers (arbitrary precision on most builds), floats (when the port enables them), complex on fuller builds.
str,bytes,bytearray,list,tuple,dict,set,frozenset.- List/dict/set comprehensions, unpacking,
*args/**kwargs, decorators, context managers. - Classes with inheritance,
@classmethod,@staticmethod,@propertyon fuller ROM levels. try/except/finally/else,raise,assert.async def,await,async for,async with— paired withasyncio.- f-strings. Template strings (PEP 750,
t"…") from 1.28.
Usual differences
| Topic | What happens |
|---|---|
| Standard library | A subset. json, re, struct, time, os, sys are there; pathlib and desktop-only modules are not. |
| Floating point | Optional on the smallest chips. Some ESP8266 builds are integer-only. |
| Error messages | Shorter. Tracebacks can omit source lines unless the build keeps them. |
| Multiple inheritance | Not supported. |
eval / exec | Present on most builds; can be compiled out. |
| Monkey-patching builtins | Restricted compared with CPython. |
| Filesystem | open() talks to the on-board flash (or an SD card), not your laptop disk, unless you are on the unix port. |
The maintained list is CPython differences in the official docs.
Identifiers you will see only here
const() from micropython freezes a value at compile time. @micropython.native and @micropython.viper emit machine code for a function. mem_info() and alloc_emergency_exception_buf() are runtime knobs. These are not CPython.