diff options
author | 2022-11-17 21:06:58 +0100 | |
---|---|---|
committer | 2022-11-17 20:06:58 +0000 | |
commit | e2798da2670c0f22684740275a03c09962e8a931 (patch) | |
tree | 1f91511641cf33bd0e005104fe84eb6e1f1a8371 | |
parent | Merge pull request #2320 from thegamecracks/intents-tag (diff) |
Edited several tags (#2322)
* Edited several tags
-rw-r--r-- | bot/resources/tags/environments.md | 10 | ||||
-rw-r--r-- | bot/resources/tags/identity.md | 18 | ||||
-rw-r--r-- | bot/resources/tags/inline.md | 2 | ||||
-rw-r--r-- | bot/resources/tags/listcomps.md | 4 | ||||
-rw-r--r-- | bot/resources/tags/local-file.md | 4 | ||||
-rw-r--r-- | bot/resources/tags/slicing.md | 2 | ||||
-rw-r--r-- | bot/resources/tags/traceback.md | 1 | ||||
-rw-r--r-- | bot/resources/tags/venv.md | 12 |
8 files changed, 34 insertions, 19 deletions
diff --git a/bot/resources/tags/environments.md b/bot/resources/tags/environments.md index 7bc69bde4..7402bbec4 100644 --- a/bot/resources/tags/environments.md +++ b/bot/resources/tags/environments.md @@ -1,12 +1,16 @@ -**Python Environments** +--- +aliases: ["envs"] +embed: + title: "Python Environments" +--- The main purpose of Python [virtual environments](https://docs.Python.org/3/library/venv.html#venv-def) is to create an isolated environment for Python projects. This means that each project can have its own dependencies, such as third party packages installed using pip, regardless of what dependencies every other project has. To see the current environment in use by Python, you can run: ```py >>> import sys ->>> print(sys.executable) -/usr/bin/python3 +>>> sys.executable +'/usr/bin/python3' ``` To see the environment in use by pip, you can do `pip debug` (`pip3 debug` for Linux/macOS). The 3rd line of the output will contain the path in use e.g. `sys.executable: /usr/bin/python3`. diff --git a/bot/resources/tags/identity.md b/bot/resources/tags/identity.md index fb2010759..f9fb0925c 100644 --- a/bot/resources/tags/identity.md +++ b/bot/resources/tags/identity.md @@ -13,12 +13,14 @@ if x == 3: ``` To check if two objects are actually the same thing in memory, use the identity comparison operator (`is`). ```py -list_1 = [1, 2, 3] -list_2 = [1, 2, 3] -if list_1 is [1, 2, 3]: - print("list_1 is list_2") -reference_to_list_1 = list_1 -if list_1 is reference_to_list_1: - print("list_1 is reference_to_list_1") -# Prints 'list_1 is reference_to_list_1' +>>> list_1 = [1, 2, 3] +>>> list_2 = [1, 2, 3] +>>> if list_1 is [1, 2, 3]: +... print("list_1 is list_2") +... +>>> reference_to_list_1 = list_1 +>>> if list_1 is reference_to_list_1: +... print("list_1 is reference_to_list_1") +... +list_1 is reference_to_list_1 ``` diff --git a/bot/resources/tags/inline.md b/bot/resources/tags/inline.md index 4ece74ef7..1c0280727 100644 --- a/bot/resources/tags/inline.md +++ b/bot/resources/tags/inline.md @@ -4,4 +4,6 @@ Inline codeblocks look `like this`. To create them you surround text with single Note that backticks are not quotes, see [this](https://superuser.com/questions/254076/how-do-i-type-the-tick-and-backtick-characters-on-windows/254077#254077) if you are struggling to find the backtick key. +If the wrapped code itself has a backtick, wrap it with two backticks from each side: \`\`back \` tick\`\` would become ``back ` tick``. + For how to make multiline codeblocks see the `!codeblock` tag. diff --git a/bot/resources/tags/listcomps.md b/bot/resources/tags/listcomps.md index ba00a4bf7..ccede4fba 100644 --- a/bot/resources/tags/listcomps.md +++ b/bot/resources/tags/listcomps.md @@ -10,8 +10,8 @@ Using list comprehensions can make this both shorter and more readable. As a lis >>> [n ** 2 for n in range(5)] [0, 1, 4, 9, 16] ``` -List comprehensions also get an `if` statement: -```python +List comprehensions also get an `if` clause: +```py >>> [n ** 2 for n in range(5) if n % 2 == 0] [0, 4, 16] ``` diff --git a/bot/resources/tags/local-file.md b/bot/resources/tags/local-file.md index 4a80e87e3..da4ac21ce 100644 --- a/bot/resources/tags/local-file.md +++ b/bot/resources/tags/local-file.md @@ -7,8 +7,8 @@ file = discord.File("/this/is/path/to/my/file.png", filename="file.png") with open("/this/is/path/to/my/file.png", "rb") as f: file = discord.File(f) ``` -When using the file-like object, you have to open it in `rb` mode. Also, in this case, passing `filename` to it is not necessary. -Please note that `filename` can't contain underscores. This is a Discord limitation. +When using the file-like object, you have to open it in `rb` ('read binary') mode. Also, in this case, passing `filename` to it is not necessary. +Please note that `filename` must not contain underscores. This is a Discord limitation. [`discord.Embed`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed) instances have a [`set_image`](https://discordpy.readthedocs.io/en/stable/api.html#discord.Embed.set_image) method which can be used to set an attachment as an image: ```py diff --git a/bot/resources/tags/slicing.md b/bot/resources/tags/slicing.md index 717fc46b7..0d82c642c 100644 --- a/bot/resources/tags/slicing.md +++ b/bot/resources/tags/slicing.md @@ -3,7 +3,7 @@ aliases: ["slice", "seqslice", "seqslicing", "sequence-slice", "sequence-slicing embed: title: "Sequence slicing" --- -*Slicing* is a way of accessing a part of a sequence by specifying a start, stop, and step. As with normal indexing, negative numbers can be used to count backwards. +**Slicing** is a way of accessing a part of a sequence by specifying a start, stop, and step. As with normal indexing, negative numbers can be used to count backwards. **Examples** ```py diff --git a/bot/resources/tags/traceback.md b/bot/resources/tags/traceback.md index e21fa6c6e..e05d8b259 100644 --- a/bot/resources/tags/traceback.md +++ b/bot/resources/tags/traceback.md @@ -10,6 +10,7 @@ Traceback (most recent call last): add_three("6") File "my_file.py", line 2, in add_three a = num + 3 + ~~~~^~~ TypeError: can only concatenate str (not "int") to str ``` If the traceback is long, use [our pastebin](https://paste.pythondiscord.com/). diff --git a/bot/resources/tags/venv.md b/bot/resources/tags/venv.md index a4fc62151..99ff2a707 100644 --- a/bot/resources/tags/venv.md +++ b/bot/resources/tags/venv.md @@ -1,4 +1,8 @@ -**Virtual Environments** +--- +aliases: ["virtualenv"] +embed: + title: "Virtual Environments" +--- Virtual environments are isolated Python environments, which make it easier to keep your system clean and manage dependencies. By default, when activated, only libraries and scripts installed in the virtual environment are accessible, preventing cross-project dependency conflicts, and allowing easy isolation of requirements. @@ -16,5 +20,7 @@ For more information, take a read of the [documentation](https://docs.python.org Tools such as [poetry](https://python-poetry.org/docs/basic-usage/) and [pipenv](https://pipenv.pypa.io/en/latest/) can manage the creation of virtual environments as well as project dependencies, making packaging and installing your project easier. -**Note:** When using Windows PowerShell, you may need to change the [execution policy](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies) first. This is only required once: -`Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser` +**Note:** When using PowerShell in Windows, you may need to change the [execution policy](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies) first. This is only required once per user: +```ps1 +Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser +``` |