diff options
| author | 2020-03-04 17:31:11 -0500 | |
|---|---|---|
| committer | 2020-03-04 17:31:11 -0500 | |
| commit | 564690f79a61944c25d62530caaae671f6afcb31 (patch) | |
| tree | e697860ca3d234bc9e3ecb904812855b7129a2fe | |
| parent | Merge branch 'master' into tags_overhaul (diff) | |
Update tag files for new linting hooks
45 files changed, 59 insertions, 59 deletions
diff --git a/bot/resources/tags/args-kwargs.md b/bot/resources/tags/args-kwargs.md index de883dea8..b440a2346 100644 --- a/bot/resources/tags/args-kwargs.md +++ b/bot/resources/tags/args-kwargs.md @@ -14,4 +14,4 @@ These special parameters allow functions to take arbitrary amounts of positional • **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* `!tags positional-keyword` *for information about positional and keyword arguments*
\ No newline at end of file +*See* `!tags positional-keyword` *for information about positional and keyword arguments* diff --git a/bot/resources/tags/ask.md b/bot/resources/tags/ask.md index ed651e8c5..e2c2a88f6 100644 --- a/bot/resources/tags/ask.md +++ b/bot/resources/tags/ask.md @@ -6,4 +6,4 @@ Asking good questions will yield a much higher chance of a quick response: • Show us the code you've tried and any errors or unexpected results it's giving. • Be patient while we're helping you. -You can find a much more detailed explanation [on our website](https://pythondiscord.com/pages/asking-good-questions/).
\ No newline at end of file +You can find a much more detailed explanation [on our website](https://pythondiscord.com/pages/asking-good-questions/). diff --git a/bot/resources/tags/class.md b/bot/resources/tags/class.md index 74c36b9fa..4f73fc974 100644 --- a/bot/resources/tags/class.md +++ b/bot/resources/tags/class.md @@ -10,7 +10,7 @@ Here is an example class: class Foo: def __init__(self, somedata): self.my_attrib = somedata - + def show(self): print(self.my_attrib) ``` @@ -22,4 +22,4 @@ bar = Foo('data') bar.show() ``` -We can access any of `Foo`'s methods via `bar.my_method()`, and access any of `bar`s data via `bar.my_attribute`.
\ No newline at end of file +We can access any of `Foo`'s methods via `bar.my_method()`, and access any of `bar`s data via `bar.my_attribute`. diff --git a/bot/resources/tags/classmethod.md b/bot/resources/tags/classmethod.md index 43c6d9909..a4e803093 100644 --- a/bot/resources/tags/classmethod.md +++ b/bot/resources/tags/classmethod.md @@ -17,4 +17,4 @@ alternative_bot = Bot.from_config(default_config) # but this still works, too regular_bot = Bot("tokenstring") ``` -This is just one of the many use cases of `@classmethod`. A more in-depth explanation can be found [here](https://stackoverflow.com/questions/12179271/meaning-of-classmethod-and-staticmethod-for-beginner#12179752).
\ No newline at end of file +This is just one of the many use cases of `@classmethod`. A more in-depth explanation can be found [here](https://stackoverflow.com/questions/12179271/meaning-of-classmethod-and-staticmethod-for-beginner#12179752). diff --git a/bot/resources/tags/codeblock.md b/bot/resources/tags/codeblock.md index 34db060ef..a28ae397b 100644 --- a/bot/resources/tags/codeblock.md +++ b/bot/resources/tags/codeblock.md @@ -14,4 +14,4 @@ Note: This will result in the following: ```py print('Hello world!') -```
\ No newline at end of file +``` diff --git a/bot/resources/tags/decorators.md b/bot/resources/tags/decorators.md index 9b53af064..39c943f0a 100644 --- a/bot/resources/tags/decorators.md +++ b/bot/resources/tags/decorators.md @@ -12,12 +12,12 @@ Consider the following example of a timer decorator: ... print('Time elapsed:', time.time() - start) ... return result ... return inner -... +... >>> @timer ... def slow(delay=1): ... time.sleep(delay) ... return 'Finished!' -... +... >>> print(slow()) Time elapsed: 1.0011568069458008 Finished! @@ -28,4 +28,4 @@ Finished! More information: • [Corey Schafer's video on decorators](https://youtu.be/FsAPt_9Bf3U) -• [Real python article](https://realpython.com/primer-on-python-decorators/)
\ No newline at end of file +• [Real python article](https://realpython.com/primer-on-python-decorators/) diff --git a/bot/resources/tags/dictcomps.md b/bot/resources/tags/dictcomps.md index ddefa1299..11867d77b 100644 --- a/bot/resources/tags/dictcomps.md +++ b/bot/resources/tags/dictcomps.md @@ -17,4 +17,4 @@ They are also very useful for inverting the key value pairs of a dictionary that Also like list comprehensions, you can add a conditional to it in order to filter out items you don't want. -For more information and examples, check [PEP 274](https://www.python.org/dev/peps/pep-0274/)
\ No newline at end of file +For more information and examples, check [PEP 274](https://www.python.org/dev/peps/pep-0274/) diff --git a/bot/resources/tags/enumerate.md b/bot/resources/tags/enumerate.md index 610843cf4..dd984af52 100644 --- a/bot/resources/tags/enumerate.md +++ b/bot/resources/tags/enumerate.md @@ -4,10 +4,10 @@ index = 0 for item in my_list: print(f"{index}: {item}") index += 1 -``` +``` into beautiful, _pythonic_ code: ```py for index, item in enumerate(my_list): print(f"{index}: {item}") ``` -For more information, check out [the official docs](https://docs.python.org/3/library/functions.html#enumerate), or [PEP 279](https://www.python.org/dev/peps/pep-0279/).
\ No newline at end of file +For more information, check out [the official docs](https://docs.python.org/3/library/functions.html#enumerate), or [PEP 279](https://www.python.org/dev/peps/pep-0279/). diff --git a/bot/resources/tags/except.md b/bot/resources/tags/except.md index 66dce13ab..8f0abf156 100644 --- a/bot/resources/tags/except.md +++ b/bot/resources/tags/except.md @@ -14,4 +14,4 @@ try: except: print("An exception was raised, but we have no idea if it was a ValueError or an IndexError.") ``` -For more information about exception handling, see [the official Python docs](https://docs.python.org/3/tutorial/errors.html), or watch [Corey Schafer's video on exception handling](https://www.youtube.com/watch?v=NIWwJbo-9_8).
\ No newline at end of file +For more information about exception handling, see [the official Python docs](https://docs.python.org/3/tutorial/errors.html), or watch [Corey Schafer's video on exception handling](https://www.youtube.com/watch?v=NIWwJbo-9_8). diff --git a/bot/resources/tags/exit().md b/bot/resources/tags/exit().md index 89f83f7e0..27da9f866 100644 --- a/bot/resources/tags/exit().md +++ b/bot/resources/tags/exit().md @@ -5,4 +5,4 @@ If you want to exit your code programmatically, you might think to use the funct You should use either [`SystemExit`](https://docs.python.org/3/library/exceptions.html#SystemExit) or [`sys.exit()`](https://docs.python.org/3/library/sys.html#sys.exit) instead. There's not much practical difference between these two other than having to `import sys` for the latter. Both take an optional argument to provide an exit status. -[Official documentation](https://docs.python.org/3/library/constants.html#exit) with the warning not to use `exit()` or `quit()` in source code.
\ No newline at end of file +[Official documentation](https://docs.python.org/3/library/constants.html#exit) with the warning not to use `exit()` or `quit()` in source code. diff --git a/bot/resources/tags/f-strings.md b/bot/resources/tags/f-strings.md index 966fe6080..69bc82487 100644 --- a/bot/resources/tags/f-strings.md +++ b/bot/resources/tags/f-strings.md @@ -14,4 +14,4 @@ print("{0} are some of the largest snakes in the world".format(snake)) # Or keyword arguments print("{family} are some of the largest snakes in the world".format(family=snake)) -```
\ No newline at end of file +``` diff --git a/bot/resources/tags/foo.md b/bot/resources/tags/foo.md index 2b5b659fd..98529bfc0 100644 --- a/bot/resources/tags/foo.md +++ b/bot/resources/tags/foo.md @@ -7,4 +7,4 @@ Python has its own metasyntactic variables, namely `spam`, `eggs`, and `bacon`. More information: • [History of foobar](https://en.wikipedia.org/wiki/Foobar) -• [Monty Python sketch](https://en.wikipedia.org/wiki/Spam_%28Monty_Python%29)
\ No newline at end of file +• [Monty Python sketch](https://en.wikipedia.org/wiki/Spam_%28Monty_Python%29) diff --git a/bot/resources/tags/functions-are-objects.md b/bot/resources/tags/functions-are-objects.md index d10e6b73e..01af7a721 100644 --- a/bot/resources/tags/functions-are-objects.md +++ b/bot/resources/tags/functions-are-objects.md @@ -36,4 +36,4 @@ class C: # open function is passed # to the staticmethod class -```
\ No newline at end of file +``` diff --git a/bot/resources/tags/global.md b/bot/resources/tags/global.md index fc60f9177..64c316b62 100644 --- a/bot/resources/tags/global.md +++ b/bot/resources/tags/global.md @@ -13,4 +13,4 @@ def update_score(score, roll): return score + roll score = update_score(score, roll) ``` -For in-depth explanations on why global variables are bad news in a variety of situations, see [this Stack Overflow answer](https://stackoverflow.com/questions/19158339/why-are-global-variables-evil/19158418#19158418).
\ No newline at end of file +For in-depth explanations on why global variables are bad news in a variety of situations, see [this Stack Overflow answer](https://stackoverflow.com/questions/19158339/why-are-global-variables-evil/19158418#19158418). diff --git a/bot/resources/tags/if-name-main.md b/bot/resources/tags/if-name-main.md index d44f0086d..9d88bb897 100644 --- a/bot/resources/tags/if-name-main.md +++ b/bot/resources/tags/if-name-main.md @@ -23,4 +23,4 @@ If you run this module named `bar.py`, it will execute the code in `foo.py`. Fir • 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
\ No newline at end of file +• 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/indent.md b/bot/resources/tags/indent.md index 5b36a4818..dec8407b0 100644 --- a/bot/resources/tags/indent.md +++ b/bot/resources/tags/indent.md @@ -12,7 +12,7 @@ def foo(): print('ham') # indented two levels return bar # indented one level ``` -The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the `if` statement, and will only run if the `if` statement evaluates to `True`. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the `if` statement above as no more lines can be inside the `if` statement below that line. +The first line is not indented. The next two lines are indented to be inside of the function definition. They will only run when the function is called. The fourth line is indented to be inside the `if` statement, and will only run if the `if` statement evaluates to `True`. The fifth and last line is like the 2nd and 3rd and will always run when the function is called. It effectively closes the `if` statement above as no more lines can be inside the `if` statement below that line. **Indentation is used after:** **1.** [Compound statements](https://docs.python.org/3/reference/compound_stmts.html) (eg. `if`, `while`, `for`, `try`, `with`, `def`, `class`, and their counterparts) @@ -21,4 +21,4 @@ The first line is not indented. The next two lines are indented to be inside of **More Info** **1.** [Indentation style guide](https://www.python.org/dev/peps/pep-0008/#indentation) **2.** [Tabs or Spaces?](https://www.python.org/dev/peps/pep-0008/#tabs-or-spaces) -**3.** [Official docs on indentation](https://docs.python.org/3/reference/lexical_analysis.html#indentation)
\ No newline at end of file +**3.** [Official docs on indentation](https://docs.python.org/3/reference/lexical_analysis.html#indentation) diff --git a/bot/resources/tags/inline.md b/bot/resources/tags/inline.md index d0c9d1b5e..a6a7c35d6 100644 --- a/bot/resources/tags/inline.md +++ b/bot/resources/tags/inline.md @@ -13,4 +13,4 @@ The `__init__` method customizes the newly created instance. **Note:** • These are **backticks** not quotes • Avoid using them for multiple lines -• Useful for negating formatting you don't want
\ No newline at end of file +• Useful for negating formatting you don't want diff --git a/bot/resources/tags/iterate-dict.md b/bot/resources/tags/iterate-dict.md index b23475506..78c067b20 100644 --- a/bot/resources/tags/iterate-dict.md +++ b/bot/resources/tags/iterate-dict.md @@ -7,4 +7,4 @@ To iterate over both the keys and values: ```py for key, val in my_dict.items(): print(key, val) -```
\ No newline at end of file +``` diff --git a/bot/resources/tags/listcomps.md b/bot/resources/tags/listcomps.md index 5ef0ce2bc..0003b9bb8 100644 --- a/bot/resources/tags/listcomps.md +++ b/bot/resources/tags/listcomps.md @@ -11,4 +11,4 @@ even_numbers = [n for n in range(20) if n % 2 == 0] ``` This also works for generators, dicts and sets by using `()` or `{}` instead of `[]`. -For more info, see [this pythonforbeginners.com post](http://www.pythonforbeginners.com/basics/list-comprehensions-in-python) or [PEP 202](https://www.python.org/dev/peps/pep-0202/).
\ No newline at end of file +For more info, see [this pythonforbeginners.com post](http://www.pythonforbeginners.com/basics/list-comprehensions-in-python) or [PEP 202](https://www.python.org/dev/peps/pep-0202/). diff --git a/bot/resources/tags/mutable-default-args.md b/bot/resources/tags/mutable-default-args.md index 7b16e6b82..a8f0c38b3 100644 --- a/bot/resources/tags/mutable-default-args.md +++ b/bot/resources/tags/mutable-default-args.md @@ -11,7 +11,7 @@ and returns it. `foo` is set to an empty list by default. >>> def append_one(foo=[]): ... foo.append(1) ... return foo -... +... ``` See what happens when we call it a few times: ```python @@ -33,7 +33,7 @@ function is **called**: ... foo = [] ... foo.append(1) ... return foo -... +... >>> append_one() [1] >>> append_one() @@ -45,4 +45,4 @@ function is **called**: • 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 -arguments are evaulated only once when the function is defined.
\ No newline at end of file +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 462c550bc..3e76269f7 100644 --- a/bot/resources/tags/names.md +++ b/bot/resources/tags/names.md @@ -34,4 +34,4 @@ 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)
\ No newline at end of file +• [Official documentation](https://docs.python.org/3/reference/executionmodel.html#naming-and-binding) diff --git a/bot/resources/tags/off-topic.md b/bot/resources/tags/off-topic.md index 004adfa17..c7f98a813 100644 --- a/bot/resources/tags/off-topic.md +++ b/bot/resources/tags/off-topic.md @@ -1,8 +1,8 @@ **Off-topic channels** -There are three off-topic channels: -• <#291284109232308226> +There are three off-topic channels: +• <#291284109232308226> • <#463035241142026251> • <#463035268514185226> -Their names change randomly every 24 hours, but you can always find them under the `OFF-TOPIC/GENERAL` category in the channel list.
\ No newline at end of file +Their names change randomly every 24 hours, but you can always find them under the `OFF-TOPIC/GENERAL` category in the channel list. diff --git a/bot/resources/tags/open.md b/bot/resources/tags/open.md index 1ba19dedd..13b4555b9 100644 --- a/bot/resources/tags/open.md +++ b/bot/resources/tags/open.md @@ -23,4 +23,4 @@ This is an optional string that specifies the mode in which the file should be o `'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)
\ No newline at end of file +`'a+'` Opens file for reading and writing at **end of file** (can create files) diff --git a/bot/resources/tags/or-gotcha.md b/bot/resources/tags/or-gotcha.md index da82e3fdd..00c2db1f8 100644 --- a/bot/resources/tags/or-gotcha.md +++ b/bot/resources/tags/or-gotcha.md @@ -14,4 +14,4 @@ if favorite_fruit == 'grapefruit' or favorite_fruit == 'lemon': # ...or like this. if favorite_fruit in ('grapefruit', 'lemon'): print("That's a weird favorite fruit to have.") -```
\ No newline at end of file +``` diff --git a/bot/resources/tags/param-arg.md b/bot/resources/tags/param-arg.md index 9e946812b..88069d8bd 100644 --- a/bot/resources/tags/param-arg.md +++ b/bot/resources/tags/param-arg.md @@ -9,4 +9,4 @@ def square(n): # n is the parameter print(square(5)) # 5 is the argument ``` -Note that `5` is the argument passed to `square`, but `square(5)` in its entirety is the argument passed to `print`
\ No newline at end of file +Note that `5` is the argument passed to `square`, but `square(5)` in its entirety is the argument passed to `print` diff --git a/bot/resources/tags/paste.md b/bot/resources/tags/paste.md index d8e6e6c61..2ed51def7 100644 --- a/bot/resources/tags/paste.md +++ b/bot/resources/tags/paste.md @@ -3,4 +3,4 @@ If your code is too long to fit in a codeblock in discord, you can paste your code here: https://paste.pydis.com/ -After pasting your code, **save** it by clicking the floppy disk icon in the top right, or by typing `ctrl + S`. After doing that, the URL should **change**. Copy the URL and post it here so others can see it.
\ No newline at end of file +After pasting your code, **save** it by clicking the floppy disk icon in the top right, or by typing `ctrl + S`. After doing that, the URL should **change**. Copy the URL and post it here so others can see it. diff --git a/bot/resources/tags/pathlib.md b/bot/resources/tags/pathlib.md index 468945cc5..dfeb7ecac 100644 --- a/bot/resources/tags/pathlib.md +++ b/bot/resources/tags/pathlib.md @@ -18,4 +18,4 @@ Python 3 comes with a new module named `Pathlib`. Since Python 3.6, `pathlib.Pat • [**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://www.python.org/dev/peps/pep-0519/)
\ No newline at end of file +• [**PEP 519** - Adding a file system path protocol](https://www.python.org/dev/peps/pep-0519/) diff --git a/bot/resources/tags/pep8.md b/bot/resources/tags/pep8.md index ec999bedc..cab4c4db8 100644 --- a/bot/resources/tags/pep8.md +++ b/bot/resources/tags/pep8.md @@ -1,3 +1,3 @@ **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. -You can find the PEP 8 document [here](https://www.python.org/dev/peps/pep-0008).
\ No newline at end of file +You can find the PEP 8 document [here](https://www.python.org/dev/peps/pep-0008). diff --git a/bot/resources/tags/positional-keyword.md b/bot/resources/tags/positional-keyword.md index bc7f68ee0..dd6ddfc4b 100644 --- a/bot/resources/tags/positional-keyword.md +++ b/bot/resources/tags/positional-keyword.md @@ -25,7 +25,7 @@ The reverse is also true: ```py >>> def foo(a, b): ... print(a, b) -... +... >>> foo(a=1, b=2) 1 2 >>> foo(b=1, a=2) @@ -35,4 +35,4 @@ The reverse is also true: **More info** • [Keyword only arguments](https://www.python.org/dev/peps/pep-3102/) • [Positional only arguments](https://www.python.org/dev/peps/pep-0570/) -• `!tags param-arg` (Parameters vs. Arguments)
\ No newline at end of file +• `!tags param-arg` (Parameters vs. Arguments) diff --git a/bot/resources/tags/precedence.md b/bot/resources/tags/precedence.md index 8a4c66c4e..ed399143c 100644 --- a/bot/resources/tags/precedence.md +++ b/bot/resources/tags/precedence.md @@ -10,4 +10,4 @@ Operator precedence is essentially like an order of operations for python's oper `not True or True` is `True` because the `not` is first `not (True or True)` is `False` because the `or` is first -The full table of precedence from lowest to highest is [here](https://docs.python.org/3/reference/expressions.html#operator-precedence)
\ No newline at end of file +The full table of precedence from lowest to highest is [here](https://docs.python.org/3/reference/expressions.html#operator-precedence) diff --git a/bot/resources/tags/quotes.md b/bot/resources/tags/quotes.md index bb6e2a009..8421748a1 100644 --- a/bot/resources/tags/quotes.md +++ b/bot/resources/tags/quotes.md @@ -17,4 +17,4 @@ If you need both single and double quotes inside your string, use the version th **References:** • [pep-8 on quotes](https://www.python.org/dev/peps/pep-0008/#string-quotes) -• [convention for triple quoted strings](https://www.python.org/dev/peps/pep-0257/)
\ No newline at end of file +• [convention for triple quoted strings](https://www.python.org/dev/peps/pep-0257/) diff --git a/bot/resources/tags/relative-path.md b/bot/resources/tags/relative-path.md index 269276e81..6e97b78af 100644 --- a/bot/resources/tags/relative-path.md +++ b/bot/resources/tags/relative-path.md @@ -4,4 +4,4 @@ A relative path is a partial path that is relative to your current working direc **Why is this important?** -When opening files in python, relative paths won't always work since it's dependent on what directory you were in when you ran your code. A common issue people face is running their code in an IDE thinking they can open files that are in the same directory as their module, but the current working directory will be different than what they expect and so they won't find the file. The way to avoid this problem is by using absolute paths, which is the full path from your root directory to the file you want to open.
\ No newline at end of file +When opening files in python, relative paths won't always work since it's dependent on what directory you were in when you ran your code. A common issue people face is running their code in an IDE thinking they can open files that are in the same directory as their module, but the current working directory will be different than what they expect and so they won't find the file. The way to avoid this problem is by using absolute paths, which is the full path from your root directory to the file you want to open. diff --git a/bot/resources/tags/repl.md b/bot/resources/tags/repl.md index a68fe9397..875b4ec47 100644 --- a/bot/resources/tags/repl.md +++ b/bot/resources/tags/repl.md @@ -10,4 +10,4 @@ Alternatively, you can make use of the builtin `help()` function. `help(thing)` Lastly you can run your code with the `-i` flag to execute your code normally, but be dropped into the REPL once execution is finished, giving you access to all your global variables/functions in the REPL. -To **exit** either a help session, or normal REPL prompt, you must send an EOF signal to the prompt. In *nix systems, this is done with `ctrl + D`, and in windows systems it is `ctrl + Z`. You can also exit the normal REPL prompt with the dedicated functions `exit()` or `quit()`.
\ No newline at end of file +To **exit** either a help session, or normal REPL prompt, you must send an EOF signal to the prompt. In *nix systems, this is done with `ctrl + D`, and in windows systems it is `ctrl + Z`. You can also exit the normal REPL prompt with the dedicated functions `exit()` or `quit()`. diff --git a/bot/resources/tags/return.md b/bot/resources/tags/return.md index c944dddf2..e37f0eebc 100644 --- a/bot/resources/tags/return.md +++ b/bot/resources/tags/return.md @@ -16,13 +16,13 @@ If we wanted to store 5 squared in a variable called `x`, we could do that like ```py >>> def square(n): ... n*n # calculates then throws away, returns None -... +... >>> x = square(5) >>> print(x) None >>> def square(n): ... print(n*n) # calculates and prints, then throws away and returns None -... +... >>> x = square(5) 25 >>> print(x) @@ -32,4 +32,4 @@ None • `print()` and `return` do **not** accomplish the same thing. `print()` will only print the value, it will not be accessible outside of the function afterwards. • A function will return `None` if it ends without reaching an explicit `return` statement. • When you want to print a value calculated in a function, instead of printing inside the function, it is often better to return the value and print the *function call* instead. -• [Official documentation for `return`](https://docs.python.org/3/reference/simple_stmts.html#the-return-statement)
\ No newline at end of file +• [Official documentation for `return`](https://docs.python.org/3/reference/simple_stmts.html#the-return-statement) diff --git a/bot/resources/tags/round.md b/bot/resources/tags/round.md index 28a12469a..0392bb41b 100644 --- a/bot/resources/tags/round.md +++ b/bot/resources/tags/round.md @@ -21,4 +21,4 @@ It should be noted that round half to even distorts the distribution by increasi • [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)
\ No newline at end of file +• [How to force rounding technique](https://stackoverflow.com/a/10826537/4607272) diff --git a/bot/resources/tags/scope.md b/bot/resources/tags/scope.md index c1eeb3b84..5c1e64e1c 100644 --- a/bot/resources/tags/scope.md +++ b/bot/resources/tags/scope.md @@ -13,7 +13,7 @@ Alternatively if a variable is defined within a function block for example, it i ... def inner(): ... print(foo) # has access to foo from scope of outer ... return inner # brings inner to scope of caller -... +... >>> inner = outer() # get inner function >>> inner() # prints variable foo without issue bar @@ -21,4 +21,4 @@ bar **Official Documentation** **1.** [Program structure, name binding and resolution](https://docs.python.org/3/reference/executionmodel.html#execution-model) **2.** [`global` statement](https://docs.python.org/3/reference/simple_stmts.html#the-global-statement) -**3.** [`nonlocal` statement](https://docs.python.org/3/reference/simple_stmts.html#the-nonlocal-statement)
\ No newline at end of file +**3.** [`nonlocal` statement](https://docs.python.org/3/reference/simple_stmts.html#the-nonlocal-statement) diff --git a/bot/resources/tags/seek.md b/bot/resources/tags/seek.md index ff6569a0c..bc013fe03 100644 --- a/bot/resources/tags/seek.md +++ b/bot/resources/tags/seek.md @@ -19,4 +19,4 @@ Finally, lets do `f.seek(-4, 2)`, moving our stream position *backwards* 4 bytes **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.
\ No newline at end of file +• `os.SEEK_CUR` is only usable when the file is in byte mode. diff --git a/bot/resources/tags/self.md b/bot/resources/tags/self.md index a9cd5e9df..d20154fd5 100644 --- a/bot/resources/tags/self.md +++ b/bot/resources/tags/self.md @@ -22,4 +22,4 @@ doing `Foo.spam(foo, 'ham')`. Methods do not inherently have access to attributes defined in the class. In order for any one method to be able to access other methods or variables defined in the class, it must have access to the instance. -Consider if outside the class, we tried to do this: `spam(foo, 'ham')`. This would give an error, because we don't have access to the `spam` method directly, we have to call it by doing `foo.spam('ham')`. This is also the case inside of the class. If we wanted to call the `bar` method inside the `spam` method, we'd have to do `self.bar()`, just doing `bar()` would give an error.
\ No newline at end of file +Consider if outside the class, we tried to do this: `spam(foo, 'ham')`. This would give an error, because we don't have access to the `spam` method directly, we have to call it by doing `foo.spam('ham')`. This is also the case inside of the class. If we wanted to call the `bar` method inside the `spam` method, we'd have to do `self.bar()`, just doing `bar()` would give an error. diff --git a/bot/resources/tags/star-imports.md b/bot/resources/tags/star-imports.md index 4c7e0199c..2be6aab6e 100644 --- a/bot/resources/tags/star-imports.md +++ b/bot/resources/tags/star-imports.md @@ -45,4 +45,4 @@ Conclusion: Namespaces are one honking great idea -- let's do more of those! *[3 **[2]** [Namespaces and scopes](https://www.programiz.com/python-programming/namespace) -**[3]** [Zen of Python](https://www.python.org/dev/peps/pep-0020/)
\ No newline at end of file +**[3]** [Zen of Python](https://www.python.org/dev/peps/pep-0020/) diff --git a/bot/resources/tags/traceback.md b/bot/resources/tags/traceback.md index 678ba1991..46ef40aa1 100644 --- a/bot/resources/tags/traceback.md +++ b/bot/resources/tags/traceback.md @@ -15,4 +15,4 @@ The best way to read your traceback is bottom to top. • Make note of the line number, and navigate there in your program. • Try to understand why the error occurred. -To read more about exceptions and errors, please refer to the [PyDis Wiki](https://pythondiscord.com/pages/asking-good-questions/#examining-tracebacks) or the [official Python tutorial.](https://docs.python.org/3.7/tutorial/errors.html)
\ No newline at end of file +To read more about exceptions and errors, please refer to the [PyDis Wiki](https://pythondiscord.com/pages/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 d8723f06f..da8edf685 100644 --- a/bot/resources/tags/windows-path.md +++ b/bot/resources/tags/windows-path.md @@ -1,6 +1,6 @@ **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 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 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. @@ -27,4 +27,4 @@ C:\Users\Username> py -3.6 ... Python 3.6 stars ... C:\Users\Username> py -2 ... Python 2 (any version installed) starts ... -```
\ No newline at end of file +``` diff --git a/bot/resources/tags/with.md b/bot/resources/tags/with.md index a79eb7dbb..62d5612f2 100644 --- a/bot/resources/tags/with.md +++ b/bot/resources/tags/with.md @@ -5,4 +5,4 @@ with open("test.txt", "r") as file: ``` The above code automatically closes `file` when the `with` block exits, so you never have to manually do a `file.close()`. Most connection types, including file readers and database connections, support this. -For more information, read [the official docs](https://docs.python.org/3/reference/compound_stmts.html#with), watch [Corey Schafer\'s context manager video](https://www.youtube.com/watch?v=-aKFBoZpiqA), or see [PEP 343](https://www.python.org/dev/peps/pep-0343/).
\ No newline at end of file +For more information, read [the official docs](https://docs.python.org/3/reference/compound_stmts.html#with), watch [Corey Schafer\'s context manager video](https://www.youtube.com/watch?v=-aKFBoZpiqA), or see [PEP 343](https://www.python.org/dev/peps/pep-0343/). diff --git a/bot/resources/tags/xy-problem.md b/bot/resources/tags/xy-problem.md index 77700e7a0..b77bd27e8 100644 --- a/bot/resources/tags/xy-problem.md +++ b/bot/resources/tags/xy-problem.md @@ -4,4 +4,4 @@ Asking about your attempted solution rather than your actual problem. Often programmers will get distracted with a potential solution they've come up with, and will try asking for help getting it to work. However, it's possible this solution either wouldn't work as they expect, or there's a much better solution instead. -For more information and examples: http://xyproblem.info/
\ No newline at end of file +For more information and examples: http://xyproblem.info/ diff --git a/bot/resources/tags/ytdl.md b/bot/resources/tags/ytdl.md index e1085d1af..09664af26 100644 --- a/bot/resources/tags/ytdl.md +++ b/bot/resources/tags/ytdl.md @@ -6,4 +6,4 @@ For reference, this usage is covered by the following clauses in [YouTube's TOS] ``` ``` 4C: You agree not to access Content through any technology or means other than the video playback pages of the Service itself, the Embeddable Player, or other explicitly authorized means YouTube may designate. -```
\ No newline at end of file +``` diff --git a/bot/resources/tags/zip.md b/bot/resources/tags/zip.md index 9d2fe5ee3..6b05f0282 100644 --- a/bot/resources/tags/zip.md +++ b/bot/resources/tags/zip.md @@ -9,4 +9,4 @@ for letter, number in zip(letters, numbers): ``` The `zip()` iterator is exhausted after the length of the shortest iterable is exceeded. If you would like to retain the other values, consider using [itertools.zip_longest](https://docs.python.org/3/library/itertools.html#itertools.zip_longest). -For more information on zip, please refer to the [official documentation](https://docs.python.org/3/library/functions.html#zip).
\ No newline at end of file +For more information on zip, please refer to the [official documentation](https://docs.python.org/3/library/functions.html#zip). |