diff options
author | Damien George <damien@micropython.org> | 2020-06-16 21:42:44 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-06-16 22:02:24 +1000 |
commit | 178395031157f61af5426add2de1d76d91440b21 (patch) | |
tree | 4f4898ff7f2e707e5b5e4a7245422b07689fb338 /py/mpconfig.h | |
parent | 0fd91e39b1711772c88cfe4e0aaf817fe3387ba6 (diff) |
py/compile: Implement PEP 572, assignment expressions with := operator.
The syntax matches CPython and the semantics are equivalent except that,
unlike CPython, MicroPython allows using := to assign to comprehension
iteration variables, because disallowing this would take a lot of code to
check for it.
The new compile-time option MICROPY_PY_ASSIGN_EXPR selects this feature and
is enabled by default, following MICROPY_PY_ASYNC_AWAIT.
Diffstat (limited to 'py/mpconfig.h')
-rw-r--r-- | py/mpconfig.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/py/mpconfig.h b/py/mpconfig.h index 27df3f483..287b15aae 100644 --- a/py/mpconfig.h +++ b/py/mpconfig.h @@ -835,6 +835,11 @@ typedef double mp_float_t; #define MICROPY_PY_ASYNC_AWAIT (1) #endif +// Support for assignment expressions with := (see PEP 572, Python 3.8+) +#ifndef MICROPY_PY_ASSIGN_EXPR +#define MICROPY_PY_ASSIGN_EXPR (1) +#endif + // Non-standard .pend_throw() method for generators, allowing for // Future-like behavior with respect to exception handling: an // exception set with .pend_throw() will activate on the next call |