aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Izan <[email protected]>2021-09-25 21:58:44 +0100
committerGravatar Izan <[email protected]>2021-09-25 21:58:44 +0100
commit33b4f42b481e6b5e1686f66803dc916595e4b457 (patch)
tree51633078baf55743b0821d7a0eaed4537a2c3317
parentFix typos and grammar in tags (diff)
Bluenix Review
This commit should be squashed upon PR merge. - Made changes in `async-await.md`, including changing `run_until_complete()` to `asyncio.run()` - Minor changes in `traceback.md` - Rewriting `windows-path.md`
-rw-r--r--bot/resources/tags/async-await.md11
-rw-r--r--bot/resources/tags/traceback.md8
-rw-r--r--bot/resources/tags/windows-path.md21
3 files changed, 13 insertions, 27 deletions
diff --git a/bot/resources/tags/async-await.md b/bot/resources/tags/async-await.md
index 4ab8a76fc..a20332df6 100644
--- a/bot/resources/tags/async-await.md
+++ b/bot/resources/tags/async-await.md
@@ -2,7 +2,7 @@
Python provides the ability to run multiple tasks and coroutines simultaneously with the use of the `asyncio` library, which is included in the Python standard library.
-This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all the coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in threads.
+This works by running these coroutines in an event loop, where the context of the running coroutine switches periodically to allow all other coroutines to run, thus giving the appearance of running at the same time. This is different to using threads or processes in that all code runs in the main process and thread, although it is possible to run coroutines in threads.
To call an async function we can either `await` it, or run it in an event loop which we get from `asyncio`.
@@ -13,16 +13,15 @@ async def main():
```
Which means we can call `await something_awaitable()` directly from within the function. If this were a non-async function, this would have raised the exception `SyntaxError: 'await' outside async function`
-To run the top level async function from outside the event loop, we can get the event loop from `asyncio` and then use it to run the function:
+To run the top level async function from outside the event loop we need to use `[asyncio.run()`](https://docs.python.org/3/library/asyncio-task.html#asyncio.run), like this:
```py
-from asyncio import get_event_loop
+import asyncio
async def main():
await something_awaitable()
-loop = get_event_loop()
-loop.run_until_complete(main())
+asyncio.run(main())
```
-Note that in the `run_until_complete()` where we appear to be calling `main()`, this does not execute the code in `main`, rather it returns a `coroutine` object which is then handled and run by the event loop via `run_until_complete()`.
+Note that in the `asyncio.run()` where we appear to be calling `main()`, this does not execute the code in `main`, rather it returns a `coroutine` object which is then handled and run by the event loop via `asyncio.run`.
To learn more about asyncio and its use, see the [asyncio documentation](https://docs.python.org/3/library/asyncio.html).
diff --git a/bot/resources/tags/traceback.md b/bot/resources/tags/traceback.md
index be5a8bf90..321737aac 100644
--- a/bot/resources/tags/traceback.md
+++ b/bot/resources/tags/traceback.md
@@ -7,12 +7,12 @@ Traceback (most recent call last):
do_something()
File "tiny", line 2, in do_something
a = 6 / b
-ZeroDivisionError: integer division or modulo by zero
+ZeroDivisionError: division by zero
```
The best way to read your traceback is bottom to top.
-• Identify the exception raised (e.g. `ZeroDivisionError`)
-• Make note of the line number (in this case 2), and navigate there in your program.
-• Try to understand why the error occurred (in this case because `b` must be `0`).
+• Identify the exception raised (in this case `ZeroDivisionError`)
+• Make note of the line number (in this case `2`), and navigate there in your program.
+• Try to understand why the error occurred (in this case because `b` is `0`).
To read more about exceptions and errors, please refer to the [PyDis Wiki](https://pythondiscord.com/pages/guides/pydis-guides/asking-good-questions/#examining-tracebacks) or the [official Python tutorial](https://docs.python.org/3.7/tutorial/errors.html).
diff --git a/bot/resources/tags/windows-path.md b/bot/resources/tags/windows-path.md
index 3738d1bc8..e8f5690fb 100644
--- a/bot/resources/tags/windows-path.md
+++ b/bot/resources/tags/windows-path.md
@@ -1,25 +1,12 @@
**PATH on Windows**
-If you have installed Python, but you forgot to check the *Add Python to PATH* option during the installation, you may still be able to access your installation with ease.
+If you have installed Python but forgot to check the *Add Python to PATH* option during the installation, you may still be able to access your installation with ease.
-If you did not uncheck the option to install the Python launcher then you will find a `py` command on your system. If you want to be able to open your Python installation by running `python`, then your best option is to re-install Python.
+If you did not uncheck the option to install the Python launcher, then you'll instead have a `py` command which can be used in the same way. If you want to be able to access your Python installation via the `python` command, then your best option is to re-install Python (remembering to tick the `add to PATH` checkbox).
-Otherwise, you can access your installation using the `py` command in Command Prompt, where you may type something with the `python` command such as:
-```
-C:\Users\Username> python3 my_application_file.py
-```
-
-You can achieve the same result using the `py` command like this:
-```
-C:\Users\Username> py -3 my_application_file.py
-```
-
-You can pass any options to the Python interpreter after you specify a version, for example, to install a Python module using `pip` you can run:
-```
-C:\Users\Username> py -3 -m pip install numpy
-```
+You can pass any options to the Python interpreter, e.g. to install the `[numpy](https://pypi.org/project/numpy/)` module from PyPI you can run `py -3 -m pip install numpy` or `python -m pip install numpy`.
-You can also access different versions of Python using the version flag, like so:
+You can also access different versions of Python using the version flag of the `py` command, like so:
```
C:\Users\Username> py -3.7
... Python 3.7 starts ...