Skip to content

Commit c48b17d

Browse files
committed
aiorepl/README.md: More info about globals.
Signed-off-by: Jim Mussared <[email protected]>
1 parent 66924d9 commit c48b17d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

micropython/aiorepl/README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,17 @@ async def main():
5050
asyncio.run(main())
5151
```
5252

53-
The optional globals passed to `task([globals])` allows you to specify what
54-
will be in scope for the REPL. By default it uses `__main__`, which is the
55-
same scope as the regular REPL (and `main.py`). In the example above, the
56-
REPL will be able to call the `demo()` function as well as get/set the
57-
`state` variable.
53+
An optional globals dictionary can be passed to `aiorepl.task()`, which allows
54+
you to specify what will be in scope for the REPL. By default it uses the
55+
globals dictionary from the `__main__` module, which is the same scope as the
56+
regular REPL (and `main.py`). In the example above, the REPL will be able to
57+
call the `demo()` function as well as get/set the `state` variable.
58+
59+
You can also provide your own dictionary, e.g. `aiorepl.task({"obj": obj })`,
60+
or use the globals dict from the current module, e.g.
61+
`aiorepl.task(globals())`. Note that you cannot use a class instance's members
62+
dictionary, e.g. `aiorepl.task(obj.__dict__)`, as this is read-only in
63+
MicroPython.
5864

5965
Instead of the regular `>>> ` prompt, the asyncio REPL will show `--> `.
6066

0 commit comments

Comments
 (0)