scraping, 35, 43 sequence, 4, 18, 19 sets, 2, 11 shell commands, 25
From f58b9cc64aef04b505b1aeb3c8e6ae7db907504b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Wed, 15 Apr 2020 18:06:28 +0200
Subject: [PATCH 0003/1007] General fixes from List until Iterator
---
README.md | 12 ++++++------
index.html | 10 +++++-----
pdf/index_for_pdf.html | 10 +++++-----
3 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/README.md b/README.md
index 6cde05073..ae9c601b2 100644
--- a/README.md
+++ b/README.md
@@ -53,7 +53,7 @@ flatter_list = list(itertools.chain.from_iterable())
product_of_elems = functools.reduce(lambda out, el: out * el, )
list_of_chars = list()
```
-* **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.**
+* **Module [operator](#operator) provides functions itemgetter() and mul() that offer the same functionality as [lambda](#lambda) expressions above.**
```python
= .count() # Returns number of occurrences. Also works on strings.
@@ -205,7 +205,7 @@ from itertools import count, repeat, cycle, chain, islice
```
```python
- = count(start=0, step=1) # Returns incremented value endlessly.
+ = count(start=0, step=1) # Returns updated value endlessly. Accepts floats.
= repeat( [, times]) # Returns element endlessly or 'times' times.
= cycle() # Repeats the sequence endlessly.
```
@@ -261,8 +261,8 @@ Type
from types import FunctionType, MethodType, LambdaType, GeneratorType
```
-### ABC
-**An abstract base class introduces virtual subclasses that don’t inherit from it, but are still recognized by isinstance() and issubclass().**
+### Abstract Base Classes
+**Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
```python
>>> from collections.abc import Sequence, Collection, Iterable
@@ -614,7 +614,7 @@ from dateutil.tz import UTC, tzlocal, gettz, resolve_imaginary
```python
= UTC # UTC timezone. London without DST.
= tzlocal() # Local timezone. Also gettz().
- = gettz('/') # 'Continent/City_Name' timezone or None.
+ = gettz('/') # 'Continent/City_Name' timezone or None.
=
.astimezone() # Datetime, converted to passed timezone.
= .replace(tzinfo=) # Unconverted object with new timezone.
```
@@ -1106,7 +1106,7 @@ class MyHashable:
```
### Sortable
-* **With total_ordering decorator you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.**
+* **With total_ordering decorator, you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.**
```python
from functools import total_ordering
diff --git a/index.html b/index.html
index 74af62f03..286567a7e 100644
--- a/index.html
+++ b/index.html
@@ -250,7 +250,7 @@
list_of_chars = list(<str>)
-
Module operator provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.
+
Module operator provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.
<int> = <list>.count(<el>) # Returns number of occurrences. Also works on strings.
index = <list>.index(<el>) # Returns index of first occurrence or raises ValueError.
@@ -353,7 +353,7 @@
Itertools
from itertools import count, repeat, cycle, chain, islice
-
<iter> = count(start=0, step=1) # Returns incremented value endlessly.
+
<iter> = count(start=0, step=1) # Returns updated value endlessly. Accepts floats.
<iter> = repeat(<el> [, times]) # Returns element endlessly or 'times' times.
<iter> = cycle(<collection>) # Repeats the sequence endlessly.
@@ -392,7 +392,7 @@
Some types do not have built-in names, so they must be imported:
from types import FunctionType, MethodType, LambdaType, GeneratorType
-
ABC
An abstract base class introduces virtual subclasses that don’t inherit from it, but are still recognized by isinstance() and issubclass().
>>> from collections.abc import Sequence, Collection, Iterable
+
Abstract Base Classes
Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.
<tzinfo> = UTC # UTC timezone. London without DST.
<tzinfo> = tzlocal() # Local timezone. Also gettz().
-<tzinfo> = gettz('<Cont.>/<City>') # 'Continent/City_Name' timezone or None.
+<tzinfo> = gettz('<Continent>/<City>') # 'Continent/City_Name' timezone or None.
<DTa> = <DT>.astimezone(<tzinfo>) # Datetime, converted to passed timezone.
<Ta/DTa> = <T/DT>.replace(tzinfo=<tzinfo>) # Unconverted object with new timezone.
@@ -1055,7 +1055,7 @@
Sortable
-
With total_ordering decorator you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.
+
With total_ordering decorator, you only need to provide eq() and one of lt(), gt(), le() or ge() special methods.
from functools import total_ordering
@total_ordering
diff --git a/pdf/index_for_pdf.html b/pdf/index_for_pdf.html
index 636276c9f..bdfa022a5 100644
--- a/pdf/index_for_pdf.html
+++ b/pdf/index_for_pdf.html
@@ -6,7 +6,7 @@
From aaace2610cc20df7f99c517772742ec47f3cd9a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Fri, 17 Apr 2020 15:44:53 +0200
Subject: [PATCH 0004/1007] Duck types
---
README.md | 2 +-
index.html | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index ae9c601b2..c374319cf 100644
--- a/README.md
+++ b/README.md
@@ -1175,7 +1175,7 @@ class Counter:
* **Any exception that happens inside the with block is passed to the exit() method.**
* **If it wishes to suppress the exception it must return a true value.**
```python
-class MyOpen():
+class MyOpen:
def __init__(self, filename):
self.filename = filename
def __enter__(self):
diff --git a/index.html b/index.html
index 286567a7e..8b9ed8711 100644
--- a/index.html
+++ b/index.html
@@ -1120,7 +1120,7 @@
Exit() should release the resources.
Any exception that happens inside the with block is passed to the exit() method.
If it wishes to suppress the exception it must return a true value.
-
classMyOpen():
+
classMyOpen:def__init__(self, filename):
self.filename = filename
def__enter__(self):
From 72549fb6c9d50469932f7e889a77ebbd56f24bbc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Sun, 19 Apr 2020 08:38:23 +0200
Subject: [PATCH 0005/1007] General fixes from Type until Exceptions
---
README.md | 12 ++++++------
index.html | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
index c374319cf..018c97013 100644
--- a/README.md
+++ b/README.md
@@ -262,7 +262,7 @@ from types import FunctionType, MethodType, LambdaType, GeneratorType
```
### Abstract Base Classes
-**Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
+**Each abstract base class specifies a set of virtual subclasses. This classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
```python
>>> from collections.abc import Sequence, Collection, Iterable
@@ -500,7 +500,7 @@ Numbers
### Math
```python
-from math import e, pi, inf, nan
+from math import e, pi, inf, nan, isinf, isnan
from math import cos, acos, sin, asin, tan, atan, degrees, radians
from math import log, log10, log2
```
@@ -1255,7 +1255,7 @@ class MySequence:
return reversed(self.a)
```
-### Collections.abc.Sequence
+### ABC Sequence
* **It's a richer interface than the basic sequence.**
* **Extending it generates iter(), contains(), reversed(), index() and count().**
* **Unlike `'abc.Iterable'` and `'abc.Collection'`, it is not a duck type. That is why `'issubclass(MySequence, abc.Sequence)'` would return False even if MySequence had all the methods defined.**
@@ -1415,7 +1415,7 @@ BaseException
+-- NameError # Raised when a variable name is not found.
+-- OSError # Failures such as “file not found” or “disk full”.
| +-- FileNotFoundError # When a file or directory is requested but doesn't exist.
- +-- RuntimeError # Raised by errors that don't fall in other categories.
+ +-- RuntimeError # Raised by errors that don't fall into other categories.
| +-- RecursionError # Raised when the maximum recursion depth is exceeded.
+-- StopIteration # Raised by next() when run on an empty iterator.
+-- TypeError # Raised when an argument is of wrong type.
@@ -1458,8 +1458,8 @@ Exit
```python
import sys
sys.exit() # Exits with exit code 0 (success).
-sys.exit() # Exits with passed exit code.
-sys.exit() # Prints the object and exits with 1 (failure).
+sys.exit() # Prints object to stderr and exits with 1.
+sys.exit() # Exits with the passed exit code.
```
diff --git a/index.html b/index.html
index 8b9ed8711..b60ed658d 100644
--- a/index.html
+++ b/index.html
@@ -392,7 +392,7 @@
Some types do not have built-in names, so they must be imported:
from types import FunctionType, MethodType, LambdaType, GeneratorType
-
Abstract Base Classes
Each abstract base class specifies a set of virtual subclasses. This classes get recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.
>>> from collections.abc import Sequence, Collection, Iterable
+
Abstract Base Classes
Each abstract base class specifies a set of virtual subclasses. This classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.
from math import e, pi, inf, nan, isinf, isnan
from math import cos, acos, sin, asin, tan, atan, degrees, radians
from math import log, log10, log2
@@ -1194,7 +1194,7 @@
-
Collections.abc.Sequence
+
ABC Sequence
It's a richer interface than the basic sequence.
Extending it generates iter(), contains(), reversed(), index() and count().
Unlike 'abc.Iterable' and 'abc.Collection', it is not a duck type. That is why 'issubclass(MySequence, abc.Sequence)' would return False even if MySequence had all the methods defined.
@@ -1329,7 +1329,7 @@
+-- NameError # Raised when a variable name is not found.
+-- OSError # Failures such as “file not found” or “disk full”.
| +-- FileNotFoundError # When a file or directory is requested but doesn't exist.
- +-- RuntimeError # Raised by errors that don't fall in other categories.
+ +-- RuntimeError # Raised by errors that don't fall into other categories.
| +-- RecursionError # Raised when the maximum recursion depth is exceeded.
+-- StopIteration # Raised by next() when run on an empty iterator.
+-- TypeError # Raised when an argument is of wrong type.
@@ -1361,8 +1361,8 @@
Exits the interpreter by raising SystemExit exception.
import sys
sys.exit() # Exits with exit code 0 (success).
-sys.exit(<int>) # Exits with passed exit code.
-sys.exit(<obj>) # Prints the object and exits with 1 (failure).
+sys.exit(<el>) # Prints object to stderr and exits with 1.
+sys.exit(<int>) # Exits with the passed exit code.
scraping, 35, 43
-sequence, 4, 18, 19
+sequence, 4, 18, 19 sets, 2, 11 shell commands, 25 sleep function, 34
From 42f7b6513869c0375c71cf754fa1fb43cdb367a2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Sun, 19 Apr 2020 22:21:20 +0200
Subject: [PATCH 0007/1007] General fixes from Open until CSV
---
README.md | 10 +++++-----
index.html | 10 +++++-----
parse.js | 2 +-
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/README.md b/README.md
index 018c97013..86210f315 100644
--- a/README.md
+++ b/README.md
@@ -1550,7 +1550,7 @@ Open
.seek(0) # Moves to the start of the file.
.seek(offset) # Moves 'offset' chars/bytes from the start.
.seek(0, 2) # Moves to the end of the file.
-.seek(±offset, ) # Anchor: 0 start, 1 current pos., 2 end.
+.seek(±offset, ) # Anchor: 0 start, 1 current position, 2 end.
```
```python
@@ -1677,7 +1677,7 @@ os.mkdir(, mode=0o777) # Creates a directory. Mode is in octal.
```
```python
-shutil.copy(from, to) # Copies the file. 'to' can be a directory.
+shutil.copy(from, to) # Copies the file. 'to' can exist or be a dir.
shutil.copytree(from, to) # Copies the directory. 'to' must not exist.
```
@@ -1698,14 +1698,14 @@ import os
= os.popen('').read()
```
-#### Sends '1 + 1' to the calculator and captures its output:
+#### Sends '1 + 1' to the basic calculator and captures its output:
```python
>>> from subprocess import run
>>> run('bc', input='1 + 1\n', capture_output=True, encoding='utf-8')
CompletedProcess(args='bc', returncode=0, stdout='2\n', stderr='')
```
-#### Sends test.in to the calculator running in standard mode and saves its output to test.out:
+#### Sends test.in to the basic calculator running in standard mode and saves its output to test.out:
```python
>>> from shlex import split
>>> os.popen('echo 1 + 1 > test.in')
@@ -1788,7 +1788,7 @@ import csv
.writerow() # Encodes objects using `str()`.
.writerows() # Appends multiple rows.
```
-* **File must be opened with `'newline=""'` argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' line endings!**
+* **File must be opened with `'newline=""'` argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!**
### Parameters
* **`'dialect'` - Master parameter that sets the default values.**
diff --git a/index.html b/index.html
index b60ed658d..936bd2e2b 100644
--- a/index.html
+++ b/index.html
@@ -1437,7 +1437,7 @@
File Object
<file>.seek(0) # Moves to the start of the file.
<file>.seek(offset) # Moves 'offset' chars/bytes from the start.
<file>.seek(0, 2) # Moves to the end of the file.
-<bin_file>.seek(±offset, <anchor>) # Anchor: 0 start, 1 current pos., 2 end.
+<bin_file>.seek(±offset, <anchor>) # Anchor: 0 start, 1 current position, 2 end.
@@ -1527,7 +1527,7 @@
os.chdir(<path>) # Changes the current working directory.
os.mkdir(<path>, mode=0o777) # Creates a directory. Mode is in octal.
-
shutil.copy(from, to) # Copies the file. 'to' can be a directory.
+
shutil.copy(from, to) # Copies the file. 'to' can exist or be a dir.
shutil.copytree(from, to) # Copies the directory. 'to' must not exist.
os.rename(from, to) # Renames/moves the file or directory.
@@ -1541,12 +1541,12 @@
<str> = os.popen('<shell_command>').read()
-
Sends '1 + 1' to the calculator and captures its output:
>>> from subprocess import run
+
Sends '1 + 1' to the basic calculator and captures its output:
>>> from subprocess import run
>>> run('bc', input='1 + 1\n', capture_output=True, encoding='utf-8')
CompletedProcess(args='bc', returncode=0, stdout='2\n', stderr='')
-
Sends test.in to the calculator running in standard mode and saves its output to test.out:
>>> from shlex import split
+
Sends test.in to the basic calculator running in standard mode and saves its output to test.out:
File must be opened with 'newline=""' argument, or an extra '\r' will be added to every '\n' on platforms that use '\r\n' line endings!
+
File must be opened with 'newline=""' argument, or '\r' will be added in front of every '\n' on platforms that use '\r\n' line endings!
Parameters
'dialect' - Master parameter that sets the default values.
diff --git a/parse.js b/parse.js
index aaa9614ef..5a322cfc9 100755
--- a/parse.js
+++ b/parse.js
@@ -35,7 +35,7 @@ const OS_RENAME =
'os.replace(from, to) # Same, but overwrites \'to\' if it exists.\n';
const SHUTIL_COPY =
- 'shutil.copy(from, to) # Copies the file. \'to\' can be a directory.\n' +
+ 'shutil.copy(from, to) # Copies the file. \'to\' can exist or be a dir.\n' +
'shutil.copytree(from, to) # Copies the directory. \'to\' must not exist.\n';
const EVAL =
From 1649a430769706f0a9f435af8bb4cd06f84c28f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Tue, 21 Apr 2020 18:40:17 +0200
Subject: [PATCH 0008/1007] Threading
---
README.md | 6 +++---
index.html | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 86210f315..4d53c684e 100644
--- a/README.md
+++ b/README.md
@@ -1173,7 +1173,7 @@ class Counter:
* **Enter() should lock the resources and optionally return an object.**
* **Exit() should release the resources.**
* **Any exception that happens inside the with block is passed to the exit() method.**
-* **If it wishes to suppress the exception it must return a true value.**
+* **If it wishes to suppress the exception it must return a true value.**
```python
class MyOpen:
def __init__(self, filename):
@@ -2078,10 +2078,10 @@ with lock:
### Thread Pool Executor
```python
from concurrent.futures import ThreadPoolExecutor
-with ThreadPoolExecutor(max_workers=None) as executor:
+with ThreadPoolExecutor(max_workers=None) as executor: # Does not exit until done.
= executor.map(lambda x: x + 1, range(3)) # (1, 2, 3)
= executor.map(lambda x, y: x + y, 'abc', '123') # ('a1', 'b2', 'c3')
- = executor.submit( [, , ...])
+ = executor.submit( [, , ...]) # Also visible outside block.
```
#### Future:
diff --git a/index.html b/index.html
index 936bd2e2b..332442737 100644
--- a/index.html
+++ b/index.html
@@ -1119,7 +1119,7 @@
Enter() should lock the resources and optionally return an object.
Exit() should release the resources.
Any exception that happens inside the with block is passed to the exit() method.
-
If it wishes to suppress the exception it must return a true value.
+
If it wishes to suppress the exception it must return a true value.
from concurrent.futures import ThreadPoolExecutor
-with ThreadPoolExecutor(max_workers=None) as executor:
+with ThreadPoolExecutor(max_workers=None) as executor: # Does not exit until done.
<iter> = executor.map(lambda x: x + 1, range(3)) # (1, 2, 3)
<iter> = executor.map(lambda x, y: x + y, 'abc', '123') # ('a1', 'b2', 'c3')
- <Future> = executor.submit(<function> [, <arg_1>, ...])
+ <Future> = executor.submit(<function> [, <arg_1>, ...]) # Also visible outside block.
Future:
<bool> = <Future>.done() # Checks if thread has finished executing.
From d7a22a5be265114324b8bf649a89ca190059d12f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Wed, 22 Apr 2020 20:07:22 +0200
Subject: [PATCH 0009/1007] General fixes from CSV until Pygame
---
README.md | 42 +++++++++++++++++++++---------------------
index.html | 42 +++++++++++++++++++++---------------------
web/script_2.js | 4 ++--
3 files changed, 44 insertions(+), 44 deletions(-)
diff --git a/README.md b/README.md
index 4d53c684e..045d80879 100644
--- a/README.md
+++ b/README.md
@@ -1459,7 +1459,7 @@ Exit
import sys
sys.exit() # Exits with exit code 0 (success).
sys.exit() # Prints object to stderr and exits with 1.
-sys.exit() # Exits with the passed exit code.
+sys.exit() # Exits with passed exit code.
```
@@ -1476,19 +1476,19 @@ print(, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
from pprint import pprint
pprint(, width=80, depth=None, compact=False, sort_dicts=True)
```
-* **Levels deeper than 'depth' get replaced by '...'.**
+* **Levels deeper than 'depth' get replaced with '...'.**
Input
-----
-**Reads a line from user input or pipe if present.**
+**Reads a line from the user input or pipe if present.**
```python
= input(prompt=None)
```
* **Trailing newline gets stripped.**
* **Prompt string is printed to the standard output before reading input.**
-* **Raises EOFError when user hits EOF (ctrl-d) or input stream gets exhausted.**
+* **Raises EOFError when user hits EOF (ctrl-d/z) or input stream gets exhausted.**
Command Line Arguments
@@ -2132,15 +2132,15 @@ Introspection
### Variables
```python
- = dir() # Returns names of local variables (incl. functions).
- = vars() # Returns dict of local variables. Also locals().
- = globals() # Returns dict of global variables.
+ = dir() # Names of local variables (incl. functions).
+ = vars() # Dict of local variables. Also locals().
+ = globals() # Dict of global variables.
```
### Attributes
```python
- = dir(
<list> = dir() # Returns names of local variables (incl. functions).
-<dict> = vars() # Returns dict of local variables. Also locals().
-<dict> = globals() # Returns dict of global variables.
+
<list> = dir() # Names of local variables (incl. functions).
+<dict> = vars() # Dict of local variables. Also locals().
+<dict> = globals() # Dict of global variables.
-
Attributes
<list> = dir(<object>) # Returns names of object's attributes (incl. methods).
-<dict> = vars(<object>) # Returns dict of object's fields. Also <obj>.__dict__.
+
Attributes
<list> = dir(<object>) # Names of object's attributes (incl. methods).
+<dict> = vars(<object>) # Dict of object's fields. Also <obj>.__dict__.
Like in our case, new() can also be called directly, usually from a new() method of a child class (def__new__(cls):return super().__new__(cls)).
The only difference between the examples above is that my_meta_class() returns a class of type type, while MyMetaClass() returns a class of type MyMetaClass.
-
Metaclass Attribute
Right before a class is created it checks if it has a 'metaclass' attribute defined. If not, it recursively checks if any of his parents has it defined and eventually comes to type().
classMyClass(metaclass=MyMetaClass):
+
Metaclass Attribute
Right before a class is created it checks if it has the 'metaclass' attribute defined. If not, it recursively checks if any of his parents has it defined and eventually comes to type().
@@ -2535,7 +2535,7 @@
<Sound>.play() # Starts playing the sound.
-
Basic Mario Brothers Example
import collections, dataclasses, enum, io, math, pygame, urllib.request, itertools as it
+
Super Mario Bros. Example
import collections, dataclasses, enum, io, math, pygame, urllib.request, itertools as it
from random import randint
P = collections.namedtuple('P', 'x y') # Position
@@ -2574,9 +2574,9 @@
defupdate_speed(mario, tiles, pressed):
x, y = mario.spd
x += 2 * ((D.e in pressed) - (D.w in pressed))
- x = math.copysign(abs(x) - 1, x) if x else0
+ x -= x / abs(x) if x else0
y += 1if D.s notin get_boundaries(mario.rect, tiles) else (-10if D.n in pressed else0)
- mario.spd = P(*[max(-thresh, min(thresh, s)) for thresh, s in zip(MAX_SPEED, P(x, y))])
+ mario.spd = P(*[max(-limit, min(limit, s)) for limit, s in zip(MAX_SPEED, P(x, y))])
defupdate_position(mario, tiles):
old_p, delta = mario.rect.topleft, P(0, 0)
@@ -2601,7 +2601,7 @@
return next(mario.frame_cycle) if {D.w, D.e} & pressed else6
screen.fill((85, 168, 255))
mario.facing_left = (D.w in pressed) if {D.e, D.w} & pressed else mario.facing_left
- screen.blit(images[get_frame_index() + mario.facing_left*9], mario.rect)
+ screen.blit(images[get_frame_index() + mario.facing_left * 9], mario.rect)
for rect in tiles:
screen.blit(images[19if {*rect.topleft} & {0, (SIZE-1)*16} else18], rect)
pygame.display.flip()
diff --git a/web/script_2.js b/web/script_2.js
index 7dc91ccf3..7a33ab9bc 100644
--- a/web/script_2.js
+++ b/web/script_2.js
@@ -51,8 +51,8 @@ const DIAGRAM_1_B =
'┃ MyClass ──→ MyMetaClass ┃\n' +
'┃ │ ↓ ┃\n' +
'┃ object ─────→ type ←╮ ┃\n' +
- '┃ │ ↑ ╰───╯ ┃\n' +
- '┃ str ─────────╯ ┃\n' +
+ '┃ │ ↑ ╰──╯ ┃\n' +
+ '┃ str ──────────╯ ┃\n' +
'┗━━━━━━━━━━━━━┷━━━━━━━━━━━━━┛\n';
const DIAGRAM_2_A =
From 9f0af6b3ef9f0e3f9693fd3212e1b5d62362e4f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Thu, 23 Apr 2020 06:30:24 +0200
Subject: [PATCH 0010/1007] Small fixes
---
README.md | 6 +++---
index.html | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 045d80879..b4513ed44 100644
--- a/README.md
+++ b/README.md
@@ -262,7 +262,7 @@ from types import FunctionType, MethodType, LambdaType, GeneratorType
```
### Abstract Base Classes
-**Each abstract base class specifies a set of virtual subclasses. This classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
+**Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.**
```python
>>> from collections.abc import Sequence, Collection, Iterable
@@ -1458,7 +1458,7 @@ Exit
```python
import sys
sys.exit() # Exits with exit code 0 (success).
-sys.exit() # Prints object to stderr and exits with 1.
+sys.exit() # Prints to stderr and exits with 1.
sys.exit() # Exits with passed exit code.
```
@@ -1476,7 +1476,7 @@ print(, ..., sep=' ', end='\n', file=sys.stdout, flush=False)
from pprint import pprint
pprint(, width=80, depth=None, compact=False, sort_dicts=True)
```
-* **Levels deeper than 'depth' get replaced with '...'.**
+* **Levels deeper than 'depth' get replaced by '...'.**
Input
diff --git a/index.html b/index.html
index 3db3d5249..d4c60351c 100644
--- a/index.html
+++ b/index.html
@@ -392,7 +392,7 @@
Some types do not have built-in names, so they must be imported:
from types import FunctionType, MethodType, LambdaType, GeneratorType
-
Abstract Base Classes
Each abstract base class specifies a set of virtual subclasses. This classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.
>>> from collections.abc import Sequence, Collection, Iterable
+
Abstract Base Classes
Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.
Exits the interpreter by raising SystemExit exception.
import sys
sys.exit() # Exits with exit code 0 (success).
-sys.exit(<el>) # Prints object to stderr and exits with 1.
+sys.exit(<el>) # Prints to stderr and exits with 1.
sys.exit(<int>) # Exits with passed exit code.
Reads a line from the user input or pipe if present.
<str> = input(prompt=None)
From 79871494134de310d1f09b37d93b66f19bee91b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Sun, 26 Apr 2020 00:54:25 +0200
Subject: [PATCH 0011/1007] Small fixes
---
README.md | 22 +++++++++-------------
index.html | 23 +++++++++++------------
pdf/index_for_pdf.html | 2 +-
3 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/README.md b/README.md
index b4513ed44..4c1354c1b 100644
--- a/README.md
+++ b/README.md
@@ -198,7 +198,6 @@ Iterator
= list() # Returns a list of iterator's remaining elements.
```
-
### Itertools
```python
from itertools import count, repeat, cycle, chain, islice
@@ -256,7 +255,7 @@ Type
(, , )
```
-#### Some types do not have built-in names, so they must be imported:
+#### Some types don't have built-in names, so they must be imported:
```python
from types import FunctionType, MethodType, LambdaType, GeneratorType
```
@@ -469,7 +468,7 @@ Format
+---------------+-----------------+-----------------+-----------------+-----------------+
```
-### Ints
+### Integers
```python
{90:c} # 'Z'
{90:b} # '1011010'
@@ -852,7 +851,7 @@ from functools import partial
* **Partial is also useful in cases when function needs to be passed as an argument, because it enables us to set its arguments beforehand.**
* **A few examples being: `'defaultdict()'`, `'iter(, to_exclusive)'` and dataclass's `'field(default_factory=)'`.**
-### Nonlocal
+### Non-Local
**If variable is being assigned to anywhere in the scope, it is regarded as a local variable, unless it is declared as a 'global' or a 'nonlocal'.**
```python
@@ -1499,7 +1498,7 @@ script_name = sys.argv[0]
arguments = sys.argv[1:]
```
-### Argparse
+### Argument Parser
```python
from argparse import ArgumentParser, FileType
p = ArgumentParser(description=)
@@ -2141,9 +2140,6 @@ Introspection
```python
= dir() # Names of object's attributes (incl. methods).
= vars() # Dict of object's fields. Also .__dict__.
-```
-
-```python
= hasattr(, '')
value = getattr(, '')
setattr(, '', value)
@@ -2284,10 +2280,10 @@ def main(screen):
async def main_coroutine(screen):
state = {'*': P(0, 0), **{id_: P(30, 10) for id_ in range(10)}}
moves = asyncio.Queue()
- coros = (*(random_controller(id_, moves) for id_ in range(10)),
+ coros = [*[random_controller(id_, moves) for id_ in range(10)],
human_controller(screen, moves),
model(moves, state, *screen.getmaxyx()),
- view(state, screen))
+ view(state, screen)]
await asyncio.wait(coros, return_when=asyncio.FIRST_COMPLETED)
async def random_controller(id_, moves):
@@ -2929,7 +2925,7 @@ while all(event.type != pg.QUIT for event in pg.event.get()):
pg.display.flip()
```
-### Rect
+### Rectangle
**Object for storing rectangular coordinates.**
```python
= pg.Rect(x, y, width, height)
@@ -2987,9 +2983,9 @@ pg.draw.ellipse(, color, )
.play() # Starts playing the sound.
```
-### Super Mario Bros. Example
+### Basic Mario Brothers Example
```python
-import collections, dataclasses, enum, io, math, pygame, urllib.request, itertools as it
+import collections, dataclasses, enum, io, pygame, urllib.request, itertools as it
from random import randint
P = collections.namedtuple('P', 'x y') # Position
diff --git a/index.html b/index.html
index d4c60351c..fec3e5f61 100644
--- a/index.html
+++ b/index.html
@@ -389,7 +389,7 @@
Some types do not have built-in names, so they must be imported:
from types import FunctionType, MethodType, LambdaType, GeneratorType
+
Some types don't have built-in names, so they must be imported:
from types import FunctionType, MethodType, LambdaType, GeneratorType
Abstract Base Classes
Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.
from inspect import signature
<sig> = signature(<function>)
no_of_params = len(<sig>.parameters)
@@ -1980,10 +1979,10 @@
asyncdefmain_coroutine(screen):
state = {'*': P(0, 0), **{id_: P(30, 10) for id_ in range(10)}}
moves = asyncio.Queue()
- coros = (*(random_controller(id_, moves) for id_ in range(10)),
+ coros = [*[random_controller(id_, moves) for id_ in range(10)],
human_controller(screen, moves),
model(moves, state, *screen.getmaxyx()),
- view(state, screen))
+ view(state, screen)]
await asyncio.wait(coros, return_when=asyncio.FIRST_COMPLETED)
asyncdefrandom_controller(id_, moves):
@@ -2493,7 +2492,7 @@
-
Rect
Object for storing rectangular coordinates.
<Rect> = pg.Rect(x, y, width, height)
+
Rectangle
Object for storing rectangular coordinates.
<Rect> = pg.Rect(x, y, width, height)
<int> = <Rect>.x/y/centerx/centery/…
<tup.> = <Rect>.topleft/center/…
<Rect> = <Rect>.move((x, y))
@@ -2535,7 +2534,7 @@
<Sound>.play() # Starts playing the sound.
-
Super Mario Bros. Example
import collections, dataclasses, enum, io, math, pygame, urllib.request, itertools as it
+
Basic Mario Brothers Example
import collections, dataclasses, enum, io, pygame, urllib.request, itertools as it
from random import randint
P = collections.namedtuple('P', 'x y') # Position
diff --git a/pdf/index_for_pdf.html b/pdf/index_for_pdf.html
index ce187715d..2c78c791a 100644
--- a/pdf/index_for_pdf.html
+++ b/pdf/index_for_pdf.html
@@ -10,7 +10,7 @@
A
all function, 11 animation, 40 any function, 11
-argparse module, 22
+argparse module, 22 arguments, 10 arrays, 29 audio, 40-41
From 59918e02323c78b8a67ffa492cb75c9251bb25b4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?=
Date: Sun, 26 Apr 2020 09:31:18 +0200
Subject: [PATCH 0012/1007] Small Fixes
---
README.md | 4 ++--
index.html | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/README.md b/README.md
index 4c1354c1b..7e4bf543e 100644
--- a/README.md
+++ b/README.md
@@ -255,7 +255,7 @@ Type
(, , )
```
-#### Some types don't have built-in names, so they must be imported:
+#### Some types do not have built-in names, so they must be imported:
```python
from types import FunctionType, MethodType, LambdaType, GeneratorType
```
@@ -1480,7 +1480,7 @@ pprint(, width=80, depth=None, compact=False, sort_dicts=True)
Input
-----
-**Reads a line from the user input or pipe if present.**
+**Reads a line from user input or pipe if present.**
```python
= input(prompt=None)
diff --git a/index.html b/index.html
index fec3e5f61..240e7577d 100644
--- a/index.html
+++ b/index.html
@@ -389,7 +389,7 @@
Some types don't have built-in names, so they must be imported:
from types import FunctionType, MethodType, LambdaType, GeneratorType
+
Some types do not have built-in names, so they must be imported:
from types import FunctionType, MethodType, LambdaType, GeneratorType
Abstract Base Classes
Each abstract base class specifies a set of virtual subclasses. These classes are then recognized by isinstance() and issubclass() as subclasses of the ABC, although they are really not.