diff --git a/bot/exts/filtering/_ui/ui.py b/bot/exts/filtering/_ui/ui.py index 7026c7d05c..a656553b22 100644 --- a/bot/exts/filtering/_ui/ui.py +++ b/bot/exts/filtering/_ui/ui.py @@ -155,13 +155,13 @@ def format_response_error(e: ResponseCodeError) -> Embed: """Format the response error into an embed.""" description = "" if isinstance(e.response_json, list): - description = "\n".join(f"• {error}" for error in e.response_json) + description = "\n".join(f"- {error}" for error in e.response_json) elif isinstance(e.response_json, dict): if "non_field_errors" in e.response_json: non_field_errors = e.response_json.pop("non_field_errors") - description += "\n".join(f"• {error}" for error in non_field_errors) + "\n" + description += "\n".join(f"- {error}" for error in non_field_errors) + "\n" for field, errors in e.response_json.items(): - description += "\n".join(f"• {field} - {error}" for error in errors) + "\n" + description += "\n".join(f"- {field} - {error}" for error in errors) + "\n" description = description.strip() if len(description) > MAX_EMBED_DESCRIPTION: diff --git a/bot/exts/fun/off_topic_names.py b/bot/exts/fun/off_topic_names.py index 120e3b4a46..a2941932b7 100644 --- a/bot/exts/fun/off_topic_names.py +++ b/bot/exts/fun/off_topic_names.py @@ -81,7 +81,7 @@ async def toggle_ot_name_activity(self, ctx: Context, name: str, active: bool) - async def list_ot_names(self, ctx: Context, active: bool = True) -> None: """Send an embed containing active/deactivated off-topic channel names.""" result = await self.bot.api_client.get("bot/off-topic-channel-names", params={"active": json.dumps(active)}) - lines = sorted(f"• {name}" for name in result) + lines = sorted(f"- {name}" for name in result) embed = Embed( title=f"{'Active' if active else 'Deactivated'} off-topic names (`{len(result)}` total)", colour=Colour.blue() @@ -286,7 +286,7 @@ async def search_command(self, ctx: Context, *, query: OffTopicName) -> None: close_matches = difflib.get_close_matches(query, result.keys(), n=10, cutoff=0.70) # Send Results - lines = sorted(f"• {result[name]}" for name in in_matches.union(close_matches)) + lines = sorted(f"- {result[name]}" for name in in_matches.union(close_matches)) embed = Embed( title="Query results", colour=Colour.blue() diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 70a83702b3..fe7da789b4 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -19,9 +19,9 @@ NEW_POST_MSG = """ **Remember to:** -• **Ask** your Python question, not if you can ask or if there's an expert who can help. -• **Show** a code sample as text (rather than a screenshot) and the error message, if you've got one. -• **Explain** what you expect to happen and what actually happens. +- **Ask** your Python question, not if you can ask or if there's an expert who can help. +- **Show** a code sample as text (rather than a screenshot) and the error message, if you've got one. +- **Explain** what you expect to happen and what actually happens. :warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs. """ diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index 764e469cca..105f051083 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -325,7 +325,7 @@ async def get_command(self, ctx: commands.Context, *, symbol_name: str | None) - colour=discord.Colour.blue() ) - lines = sorted(f"• [`{name}`]({url})" for name, url in self.base_urls.items()) + lines = sorted(f"- [`{name}`]({url})" for name, url in self.base_urls.items()) if self.base_urls: await LinePaginator.paginate(lines, ctx, inventory_embed, max_size=400, empty=False) diff --git a/bot/exts/info/patreon.py b/bot/exts/info/patreon.py index 948568101b..1c8c443c87 100644 --- a/bot/exts/info/patreon.py +++ b/bot/exts/info/patreon.py @@ -77,7 +77,7 @@ async def send_current_supporters(self, channel: discord.abc.Messageable, automa # Filter out any members where this is not their highest tier. patrons = [member for member in role.members if get_patreon_tier(member) == tier] - patron_names = [f"• {patron}" for patron in patrons] + patron_names = [f"- {patron}" for patron in patrons] embed = discord.Embed( title=role.name, diff --git a/bot/exts/moderation/voice_gate.py b/bot/exts/moderation/voice_gate.py index 50d3188bd5..4e03340785 100644 --- a/bot/exts/moderation/voice_gate.py +++ b/bot/exts/moderation/voice_gate.py @@ -181,7 +181,7 @@ async def voice_verify(self, ctx: Context, *_) -> None: if failed: embed = discord.Embed( title="Voice Gate failed", - description=FAILED_MESSAGE.format(reasons="\n".join(f"• You {reason}." for reason in failed_reasons)), + description=FAILED_MESSAGE.format(reasons="\n".join(f"- You {reason}." for reason in failed_reasons)), color=Colour.red() ) try: diff --git a/bot/exts/moderation/watchchannels/_watchchannel.py b/bot/exts/moderation/watchchannels/_watchchannel.py index 98097c40d4..d0fc0de443 100644 --- a/bot/exts/moderation/watchchannels/_watchchannel.py +++ b/bot/exts/moderation/watchchannels/_watchchannel.py @@ -353,7 +353,7 @@ async def prepare_watched_users_data( list_data["info"] = {} for user_id, user_data in watched_iter: member = await get_or_fetch_member(ctx.guild, user_id) - line = f"• `{user_id}`" + line = f"- `{user_id}`" if member: line += f" ({member.name}#{member.discriminator})" inserted_at = user_data["inserted_at"] diff --git a/bot/exts/recruitment/talentpool/_cog.py b/bot/exts/recruitment/talentpool/_cog.py index 9c180b5abf..78084899f7 100644 --- a/bot/exts/recruitment/talentpool/_cog.py +++ b/bot/exts/recruitment/talentpool/_cog.py @@ -279,7 +279,7 @@ async def list_nominations( return ["*None*"] for nomination in nominations: - line = f"• `{nomination.user_id}`" + line = f"- `{nomination.user_id}`" member = await get_or_fetch_member(ctx.guild, nomination.user_id) if member: diff --git a/bot/resources/tags/args-kwargs.md b/bot/resources/tags/args-kwargs.md index 67d93fc40f..d9d433faba 100644 --- a/bot/resources/tags/args-kwargs.md +++ b/bot/resources/tags/args-kwargs.md @@ -11,9 +11,9 @@ These special parameters allow functions to take arbitrary amounts of positional `**kwargs` will ingest an arbitrary amount of **keyword arguments**, and store it in a dictionary. There can be **no** additional parameters **after** `**kwargs` in the parameter list. **Use cases** -• **Decorators** (see `/tag decorators`) -• **Inheritance** (overriding methods) -• **Future proofing** (in the case of the first two bullet points, if the parameters change, your code won't break) -• **Flexibility** (writing functions that behave like `dict()` or `print()`) +- **Decorators** (see `/tag decorators`) +- **Inheritance** (overriding methods) +- **Future proofing** (in the case of the first two bullet points, if the parameters change, your code won't break) +- **Flexibility** (writing functions that behave like `dict()` or `print()`) *See* `/tag positional-keyword` *for information about positional and keyword arguments* diff --git a/bot/resources/tags/blocking.md b/bot/resources/tags/blocking.md index 1999e2421f..4fe778e61a 100644 --- a/bot/resources/tags/blocking.md +++ b/bot/resources/tags/blocking.md @@ -19,8 +19,8 @@ async def ping(ctx): A blocking operation is wherever you do something without `await`ing it. This tells Python that this step must be completed before it can do anything else. Common examples of blocking operations, as simple as they may seem, include: outputting text, adding two numbers and appending an item onto a list. Most common Python libraries have an asynchronous version available to use in asynchronous contexts. **`async` libraries** -The standard async library - `asyncio` -Asynchronous web requests - `aiohttp` -Talking to PostgreSQL asynchronously - `asyncpg` -MongoDB interactions asynchronously - `motor` -Check out [this](https://github.com/timofurrer/awesome-asyncio) list for even more! +- The standard async library - `asyncio` +- Asynchronous web requests - `aiohttp` +- Talking to PostgreSQL asynchronously - `asyncpg` +- MongoDB interactions asynchronously - `motor` +- Check out [this](https://github.com/timofurrer/awesome-asyncio) list for even more! diff --git a/bot/resources/tags/contribute.md b/bot/resources/tags/contribute.md index 57eae0a7eb..b788aba214 100644 --- a/bot/resources/tags/contribute.md +++ b/bot/resources/tags/contribute.md @@ -5,9 +5,9 @@ embed: Looking to contribute to Open Source Projects for the first time? Want to add a feature or fix a bug on the bots on this server? We have on-going projects that people can contribute to, even if you've never contributed to open source before! **Projects to Contribute to** -• [Sir Lancebot](https://github.com/python-discord/sir-lancebot) - our fun, beginner-friendly bot -• [Python](https://github.com/python-discord/bot) - our utility & moderation bot -• [Site](https://github.com/python-discord/site) - resources, guides, and more +- [Sir Lancebot](https://github.com/python-discord/sir-lancebot) - our fun, beginner-friendly bot +- [Python](https://github.com/python-discord/bot) - our utility & moderation bot +- [Site](https://github.com/python-discord/site) - resources, guides, and more **Where to start** 1. Read our [contribution guide](https://pythondiscord.com/pages/guides/pydis-guides/contributing/) diff --git a/bot/resources/tags/decorators.md b/bot/resources/tags/decorators.md index 65d221d6e7..ebfb40a104 100644 --- a/bot/resources/tags/decorators.md +++ b/bot/resources/tags/decorators.md @@ -29,5 +29,5 @@ Finished! ``` More information: -• [Corey Schafer's video on decorators](https://youtu.be/FsAPt_9Bf3U) -• [Real python article](https://realpython.com/primer-on-python-decorators/) +- [Corey Schafer's video on decorators](https://youtu.be/FsAPt_9Bf3U) +- [Real python article](https://realpython.com/primer-on-python-decorators/) diff --git a/bot/resources/tags/environments.md b/bot/resources/tags/environments.md index d6ed06448d..1c1677f4d7 100644 --- a/bot/resources/tags/environments.md +++ b/bot/resources/tags/environments.md @@ -18,12 +18,12 @@ If Python's `sys.executable` doesn't match pip's, then they are currently using **Why use a virtual environment?** -• Resolve dependency issues by allowing the use of different versions of a package for different projects. For example, you could use Package A v2.7 for Project X and Package A v1.3 for Project Y. -• Make your project self-contained and reproducible by capturing all package dependencies in a requirements file. Try running `pip freeze` to see what you currently have installed! -• Keep your global `site-packages/` directory tidy by removing the need to install packages system-wide which you might only need for one project. +- Resolve dependency issues by allowing the use of different versions of a package for different projects. For example, you could use Package A v2.7 for Project X and Package A v1.3 for Project Y. +- Make your project self-contained and reproducible by capturing all package dependencies in a requirements file. Try running `pip freeze` to see what you currently have installed! +- Keep your global `site-packages/` directory tidy by removing the need to install packages system-wide which you might only need for one project. **Further reading:** -• [Python Virtual Environments: A Primer](https://realpython.com/python-virtual-environments-a-primer) -• [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) +- [Python Virtual Environments: A Primer](https://realpython.com/python-virtual-environments-a-primer) +- [pyenv: Simple Python Version Management](https://github.com/pyenv/pyenv) diff --git a/bot/resources/tags/foo.md b/bot/resources/tags/foo.md index 0a40eb991c..5605ad67e1 100644 --- a/bot/resources/tags/foo.md +++ b/bot/resources/tags/foo.md @@ -8,5 +8,5 @@ Common examples include `foobar`, `foo`, `bar`, `baz`, and `qux`. Python has its own metasyntactic variables, namely `spam`, `eggs`, and `bacon`. This is a reference to a [Monty Python](https://en.wikipedia.org/wiki/Monty_Python) sketch (the eponym of the language). More information: -• [History of foobar](https://en.wikipedia.org/wiki/Foobar) -• [Monty Python sketch](https://en.wikipedia.org/wiki/Spam_%28Monty_Python%29) +- [History of foobar](https://en.wikipedia.org/wiki/Foobar) +- [Monty Python sketch](https://en.wikipedia.org/wiki/Spam_%28Monty_Python%29) diff --git a/bot/resources/tags/if-name-main.md b/bot/resources/tags/if-name-main.md index c2a7eb289a..589c476189 100644 --- a/bot/resources/tags/if-name-main.md +++ b/bot/resources/tags/if-name-main.md @@ -23,6 +23,6 @@ If you run this module named `bar.py`, it will execute the code in `foo.py`. Fir **Why would I do this?** -• Your module is a library, but also has a special case where it can be run directly -• Your module is a library and you want to safeguard it against people running it directly (like what `pip` does) -• Your module is the main program, but has unit tests and the testing framework works by importing your module, and you want to avoid having your main code run during the test +- Your module is a library, but also has a special case where it can be run directly +- Your module is a library and you want to safeguard it against people running it directly (like what `pip` does) +- Your module is the main program, but has unit tests and the testing framework works by importing your module, and you want to avoid having your main code run during the test diff --git a/bot/resources/tags/mutable-default-args.md b/bot/resources/tags/mutable-default-args.md index b4578e6f97..a1a6d3d2a4 100644 --- a/bot/resources/tags/mutable-default-args.md +++ b/bot/resources/tags/mutable-default-args.md @@ -44,7 +44,7 @@ function is **called**: **Note**: -• This behavior can be used intentionally to maintain state between +- This behavior can be used intentionally to maintain state between calls of a function (eg. when writing a caching function). -• This behavior is not unique to mutable objects, all default +- This behavior is not unique to mutable objects, all default arguments are evaulated only once when the function is defined. diff --git a/bot/resources/tags/names.md b/bot/resources/tags/names.md index f949c861a6..bc66fa099e 100644 --- a/bot/resources/tags/names.md +++ b/bot/resources/tags/names.md @@ -26,14 +26,14 @@ y ━━ 1 ``` **Names are created in multiple ways** You might think that the only way to bind a name to an object is by using assignment, but that isn't the case. All of the following work exactly the same as assignment: -• `import` statements -• `class` and `def` -• `for` loop headers -• `as` keyword when used with `except`, `import`, and `with` -• formal parameters in function headers +- `import` statements +- `class` and `def` +- `for` loop headers +- `as` keyword when used with `except`, `import`, and `with` +- formal parameters in function headers There is also `del` which has the purpose of *unbinding* a name. **More info** -• Please watch [Ned Batchelder's talk](https://youtu.be/_AEJHKGk9ns) on names in python for a detailed explanation with examples -• [Official documentation](https://docs.python.org/3/reference/executionmodel.html#naming-and-binding) +- Please watch [Ned Batchelder's talk](https://youtu.be/_AEJHKGk9ns) on names in python for a detailed explanation with examples +- [Official documentation](https://docs.python.org/3/reference/executionmodel.html#naming-and-binding) diff --git a/bot/resources/tags/nomodule.md b/bot/resources/tags/nomodule.md index 2f420e4bc8..8b02b1b7a7 100644 --- a/bot/resources/tags/nomodule.md +++ b/bot/resources/tags/nomodule.md @@ -8,8 +8,8 @@ You can read about Python environments at `/tag environments` and `/tag venv`. Common causes of this problem include: -• You installed your package using `pip install ...`. It could be that the `pip` command is not pointing to the environment where your code runs. For greater control, you could instead run pip as a module within the python environment you specify: +- You installed your package using `pip install ...`. It could be that the `pip` command is not pointing to the environment where your code runs. For greater control, you could instead run pip as a module within the python environment you specify: ``` python -m pip install ``` -• Your editor/ide is configured to create virtual environments automatically (PyCharm is configured this way by default). +- Your editor/ide is configured to create virtual environments automatically (PyCharm is configured this way by default). diff --git a/bot/resources/tags/off-topic-names.md b/bot/resources/tags/off-topic-names.md index 44a16d0c23..8326f56fe7 100644 --- a/bot/resources/tags/off-topic-names.md +++ b/bot/resources/tags/off-topic-names.md @@ -3,9 +3,9 @@ embed: title: "Off-topic channels" --- There are three off-topic channels: -• <#291284109232308226> -• <#463035241142026251> -• <#463035268514185226> +- <#291284109232308226> +- <#463035241142026251> +- <#463035268514185226> The channel names change every night at midnight UTC and are often fun meta references to jokes or conversations that happened on the server. diff --git a/bot/resources/tags/open.md b/bot/resources/tags/open.md index 3947cb88dd..97595b5ebf 100644 --- a/bot/resources/tags/open.md +++ b/bot/resources/tags/open.md @@ -5,9 +5,9 @@ embed: The built-in function `open()` is one of several ways to open files on your computer. It accepts many different parameters, so this tag will only go over two of them (`file` and `mode`). For more extensive documentation on all these parameters, consult the [official documentation](https://docs.python.org/3/library/functions.html#open). The object returned from this function is a [file object or stream](https://docs.python.org/3/glossary.html#term-file-object), for which the full documentation can be found [here](https://docs.python.org/3/library/io.html#io.TextIOBase). See also: -• `!tags with` for information on context managers -• `!tags pathlib` for an alternative way of opening files -• `!tags seek` for information on changing your position in a file +- `!tags with` for information on context managers +- `!tags pathlib` for an alternative way of opening files +- `!tags seek` for information on changing your position in a file **The `file` parameter** @@ -21,8 +21,8 @@ See `!tags relative-path` for more information on relative paths. This is an optional string that specifies the mode in which the file should be opened. There's not enough room to discuss them all, but listed below are some of the more confusing modes. -`'r+'` Opens for reading and writing (file must already exist) -`'w+'` Opens for reading and writing and truncates (can create files) -`'x'` Creates file and opens for writing (file must **not** already exist) -`'x+'` Creates file and opens for reading and writing (file must **not** already exist) -`'a+'` Opens file for reading and writing at **end of file** (can create files) +- `'r+'` Opens for reading and writing (file must already exist) +- `'w+'` Opens for reading and writing and truncates (can create files) +- `'x'` Creates file and opens for writing (file must **not** already exist) +- `'x+'` Creates file and opens for reading and writing (file must **not** already exist) +- `'a+'` Opens file for reading and writing at **end of file** (can create files) diff --git a/bot/resources/tags/pathlib.md b/bot/resources/tags/pathlib.md index db6c1f3eb8..6e3ed85bcd 100644 --- a/bot/resources/tags/pathlib.md +++ b/bot/resources/tags/pathlib.md @@ -6,18 +6,18 @@ Python 3 comes with a new module named `Pathlib`. Since Python 3.6, `pathlib.Pat **Feature spotlight**: -• Normalizes file paths for all platforms automatically -• Has glob-like utilites (eg. `Path.glob`, `Path.rglob`) for searching files -• Can read and write files, and close them automatically -• Convenient syntax, utilising the `/` operator (e.g. `Path('~') / 'Documents'`) -• Can easily pick out components of a path (eg. name, parent, stem, suffix, anchor) -• Supports method chaining -• Move and delete files -• And much more +- Normalizes file paths for all platforms automatically +- Has glob-like utilites (eg. `Path.glob`, `Path.rglob`) for searching files +- Can read and write files, and close them automatically +- Convenient syntax, utilising the `/` operator (e.g. `Path('~') / 'Documents'`) +- Can easily pick out components of a path (eg. name, parent, stem, suffix, anchor) +- Supports method chaining +- Move and delete files +- And much more **More Info**: -• [**Why you should use pathlib** - Trey Hunner](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/) -• [**Answering concerns about pathlib** - Trey Hunner](https://treyhunner.com/2019/01/no-really-pathlib-is-great/) -• [**Official Documentation**](https://docs.python.org/3/library/pathlib.html) -• [**PEP 519** - Adding a file system path protocol](https://peps.python.org/pep-0519/) +- [**Why you should use pathlib** - Trey Hunner](https://treyhunner.com/2018/12/why-you-should-be-using-pathlib/) +- [**Answering concerns about pathlib** - Trey Hunner](https://treyhunner.com/2019/01/no-really-pathlib-is-great/) +- [**Official Documentation**](https://docs.python.org/3/library/pathlib.html) +- [**PEP 519** - Adding a file system path protocol](https://peps.python.org/pep-0519/) diff --git a/bot/resources/tags/pep8.md b/bot/resources/tags/pep8.md index 98c739e5ed..620e2fa082 100644 --- a/bot/resources/tags/pep8.md +++ b/bot/resources/tags/pep8.md @@ -5,5 +5,5 @@ embed: **PEP 8** is the official style guide for Python. It includes comprehensive guidelines for code formatting, variable naming, and making your code easy to read. Professional Python developers are usually required to follow the guidelines, and will often use code-linters like flake8 to verify that the code they're writing complies with the style guide. More information: -• [PEP 8 document](https://peps.python.org/pep-0008/) -• [Our PEP 8 song!](https://www.youtube.com/watch?v=hgI0p1zf31k) :notes: +- [PEP 8 document](https://peps.python.org/pep-0008/) +- [Our PEP 8 song!](https://www.youtube.com/watch?v=hgI0p1zf31k) :notes: diff --git a/bot/resources/tags/positional-keyword.md b/bot/resources/tags/positional-keyword.md index 1325fefc29..0e1eb464ea 100644 --- a/bot/resources/tags/positional-keyword.md +++ b/bot/resources/tags/positional-keyword.md @@ -35,6 +35,6 @@ The reverse is also true: ``` **More info** -• [Keyword only arguments](https://peps.python.org/pep-3102/) -• [Positional only arguments](https://peps.python.org/pep-0570/) -• `/tag param-arg` (Parameters vs. Arguments) +- [Keyword only arguments](https://peps.python.org/pep-3102/) +- [Positional only arguments](https://peps.python.org/pep-0570/) +- `/tag param-arg` (Parameters vs. Arguments) diff --git a/bot/resources/tags/quotes.md b/bot/resources/tags/quotes.md index cea6d0147f..dcc21c8139 100644 --- a/bot/resources/tags/quotes.md +++ b/bot/resources/tags/quotes.md @@ -18,5 +18,5 @@ Example: If you need both single and double quotes inside your string, use the version that would result in the least amount of escapes. In the case of a tie, use the quotation you use the most. **References:** -• [pep-8 on quotes](https://peps.python.org/pep-0008/#string-quotes) -• [convention for triple quoted strings](https://peps.python.org/pep-0257/) +- [pep-8 on quotes](https://peps.python.org/pep-0008/#string-quotes) +- [convention for triple quoted strings](https://peps.python.org/pep-0257/) diff --git a/bot/resources/tags/regex.md b/bot/resources/tags/regex.md index d8bbb38cd0..3883db28c9 100644 --- a/bot/resources/tags/regex.md +++ b/bot/resources/tags/regex.md @@ -14,5 +14,5 @@ We can use regex to pull out all the numbers in a sentence: ['18', '196', '3', '47'] # Notice the year is cut off ``` **See Also** -• [The re docs](https://docs.python.org/3/library/re.html) - for functions that use regex -• [regex101.com](https://regex101.com) - an interactive site for testing your regular expression +- [The re docs](https://docs.python.org/3/library/re.html) - for functions that use regex +- [regex101.com](https://regex101.com) - an interactive site for testing your regular expression diff --git a/bot/resources/tags/return.md b/bot/resources/tags/return.md index 805a17ee19..0676bbbd98 100644 --- a/bot/resources/tags/return.md +++ b/bot/resources/tags/return.md @@ -29,6 +29,6 @@ None None ``` **Things to note** -• `print()` and `return` do **not** accomplish the same thing. `print()` will show the value, and then it will be gone. -• A function will return `None` if it ends without a `return` statement. -• When you want to print a value from a function, it's best to return the value and print the *function call* instead, like `print(square(5))`. +- `print()` and `return` do **not** accomplish the same thing. `print()` will show the value, and then it will be gone. +- A function will return `None` if it ends without a `return` statement. +- When you want to print a value from a function, it's best to return the value and print the *function call* instead, like `print(square(5))`. diff --git a/bot/resources/tags/round.md b/bot/resources/tags/round.md index fc67ca2f97..aca11dec5a 100644 --- a/bot/resources/tags/round.md +++ b/bot/resources/tags/round.md @@ -20,7 +20,7 @@ The round half up technique creates a slight bias towards the larger number. Wit It should be noted that round half to even distorts the distribution by increasing the probability of evens relative to odds, however this is considered less important than the bias explained above. **References:** -• [Wikipedia article about rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_to_even) -• [Documentation on `round` function](https://docs.python.org/3/library/functions.html#round) -• [`round` in what's new in python 3](https://docs.python.org/3/whatsnew/3.0.html#builtins) (4th bullet down) -• [How to force rounding technique](https://stackoverflow.com/a/10826537/4607272) +- [Wikipedia article about rounding](https://en.wikipedia.org/wiki/Rounding#Round_half_to_even) +- [Documentation on `round` function](https://docs.python.org/3/library/functions.html#round) +- [`round` in what's new in python 3](https://docs.python.org/3/whatsnew/3.0.html#builtins) (4th bullet down) +- [How to force rounding technique](https://stackoverflow.com/a/10826537/4607272) diff --git a/bot/resources/tags/seek.md b/bot/resources/tags/seek.md index 53949506e8..542ec25df4 100644 --- a/bot/resources/tags/seek.md +++ b/bot/resources/tags/seek.md @@ -20,5 +20,5 @@ Now lets do `f.seek(4, 1)`. This will move our stream position 4 bytes forward r Finally, lets do `f.seek(-4, 2)`, moving our stream position *backwards* 4 bytes relative to the **end** of the stream. Now if we did `f.read()` to read everything after our position in the file, it would return the string `'eggs'` and also move our stream position to the end of the file. **Note** -• For the second argument in `seek()`, use `os.SEEK_SET`, `os.SEEK_CUR`, and `os.SEEK_END` in place of 0, 1, and 2 respectively. -• `os.SEEK_CUR` is only usable when the file is in byte mode. +- For the second argument in `seek()`, use `os.SEEK_SET`, `os.SEEK_CUR`, and `os.SEEK_END` in place of 0, 1, and 2 respectively. +- `os.SEEK_CUR` is only usable when the file is in byte mode. diff --git a/bot/resources/tags/sql-fstring.md b/bot/resources/tags/sql-fstring.md index b57d6cb3af..30de567b29 100644 --- a/bot/resources/tags/sql-fstring.md +++ b/bot/resources/tags/sql-fstring.md @@ -15,5 +15,5 @@ db.execute(query, params) Note: Different database libraries support different placeholder styles, e.g. `%s` and `$1`. Consult your library's documentation for details. **See Also** -• [Python sqlite3 docs](https://docs.python.org/3/library/sqlite3.html#how-to-use-placeholders-to-bind-values-in-sql-queries) - How to use placeholders to bind values in SQL queries -• [PEP-249](https://peps.python.org/pep-0249/) - A specification of how database libraries in Python should work +- [Python sqlite3 docs](https://docs.python.org/3/library/sqlite3.html#how-to-use-placeholders-to-bind-values-in-sql-queries) - How to use placeholders to bind values in SQL queries +- [PEP-249](https://peps.python.org/pep-0249/) - A specification of how database libraries in Python should work diff --git a/bot/resources/tags/star-imports.md b/bot/resources/tags/star-imports.md index 43e29fea57..236c7b5037 100644 --- a/bot/resources/tags/star-imports.md +++ b/bot/resources/tags/star-imports.md @@ -19,18 +19,18 @@ Example: >>> from math import * >>> sin(pi / 2) # uses sin from math rather than your custom sin ``` -• Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import. -• Causes ambiguity. From the example, it is unclear which `sin` function is actually being used. From the Zen of Python **[3]**: `Explicit is better than implicit.` -• Makes import order significant, which they shouldn't. Certain IDE's `sort import` functionality may end up breaking code due to namespace collision. +- Potential namespace collision. Names defined from a previous import might get shadowed by a wildcard import. +- Causes ambiguity. From the example, it is unclear which `sin` function is actually being used. From the Zen of Python **[3]**: `Explicit is better than implicit.` +- Makes import order significant, which they shouldn't. Certain IDE's `sort import` functionality may end up breaking code due to namespace collision. **How should you import?** -• Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name) +- Import the module under the module's namespace (Only import the name of the module, and names defined in the module can be used by prefixing the module's name) ```python >>> import math >>> math.sin(math.pi / 2) ``` -• Explicitly import certain names from the module +- Explicitly import certain names from the module ```python >>> from math import sin, pi >>> sin(pi / 2) diff --git a/bot/resources/tags/underscore.md b/bot/resources/tags/underscore.md index 06c525538d..3dc1ede01a 100644 --- a/bot/resources/tags/underscore.md +++ b/bot/resources/tags/underscore.md @@ -4,24 +4,24 @@ embed: title: "Meanings of underscores in identifier names" --- -• `__name__`: Used to implement special behaviour, such as the `+` operator for classes with the `__add__` method. [More info](https://dbader.org/blog/python-dunder-methods) -• `_name`: Indicates that a variable is "private" and should only be used by the class or module that defines it -• `name_`: Used to avoid naming conflicts. For example, as `class` is a keyword, you could call a variable `class_` instead -• `__name`: Causes the name to be "mangled" if defined inside a class. [More info](https://docs.python.org/3/tutorial/classes.html#private-variables) +- `__name__`: Used to implement special behaviour, such as the `+` operator for classes with the `__add__` method. [More info](https://dbader.org/blog/python-dunder-methods) +- `_name`: Indicates that a variable is "private" and should only be used by the class or module that defines it +- `name_`: Used to avoid naming conflicts. For example, as `class` is a keyword, you could call a variable `class_` instead +- `__name`: Causes the name to be "mangled" if defined inside a class. [More info](https://docs.python.org/3/tutorial/classes.html#private-variables) A single underscore, **`_`**, has multiple uses: -• To indicate an unused variable, e.g. in a for loop if you don't care which iteration you are on +- To indicate an unused variable, e.g. in a for loop if you don't care which iteration you are on ```python for _ in range(10): print("Hello World") ``` -• In the REPL, where the previous result is assigned to the variable `_` +- In the REPL, where the previous result is assigned to the variable `_` ```python >>> 1 + 1 # Evaluated and stored in `_` 2 >>> _ + 3 # Take the previous result and add 3 5 ``` -• In integer literals, e.g. `x = 1_500_000` can be written instead of `x = 1500000` to improve readability +- In integer literals, e.g. `x = 1_500_000` can be written instead of `x = 1500000` to improve readability See also ["Reserved classes of identifiers"](https://docs.python.org/3/reference/lexical_analysis.html#reserved-classes-of-identifiers) in the Python docs, and [this more detailed guide](https://dbader.org/blog/meaning-of-underscores-in-python).