From c48b17dd17d3104d397fa779e41a94098f32734f Mon Sep 17 00:00:00 2001 From: Jim Mussared Date: Fri, 21 Jul 2023 16:06:41 +1000 Subject: [PATCH] aiorepl/README.md: More info about globals. Signed-off-by: Jim Mussared --- micropython/aiorepl/README.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/micropython/aiorepl/README.md b/micropython/aiorepl/README.md index 2c3ed843..4bb11083 100644 --- a/micropython/aiorepl/README.md +++ b/micropython/aiorepl/README.md @@ -50,11 +50,17 @@ async def main(): asyncio.run(main()) ``` -The optional globals passed to `task([globals])` allows you to specify what -will be in scope for the REPL. By default it uses `__main__`, which is the -same scope as the regular REPL (and `main.py`). In the example above, the -REPL will be able to call the `demo()` function as well as get/set the -`state` variable. +An optional globals dictionary can be passed to `aiorepl.task()`, which allows +you to specify what will be in scope for the REPL. By default it uses the +globals dictionary from the `__main__` module, which is the same scope as the +regular REPL (and `main.py`). In the example above, the REPL will be able to +call the `demo()` function as well as get/set the `state` variable. + +You can also provide your own dictionary, e.g. `aiorepl.task({"obj": obj })`, +or use the globals dict from the current module, e.g. +`aiorepl.task(globals())`. Note that you cannot use a class instance's members +dictionary, e.g. `aiorepl.task(obj.__dict__)`, as this is read-only in +MicroPython. Instead of the regular `>>> ` prompt, the asyncio REPL will show `--> `.