aiorepl/README.md: More info about globals.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
pull/646/head
Jim Mussared 2023-07-21 16:06:41 +10:00
rodzic 66924d9fa1
commit c48b17dd17
1 zmienionych plików z 11 dodań i 5 usunięć

Wyświetl plik

@ -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 `--> `.