From 9cfde48198374c8c839d2e4426046e27540741e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Mon, 4 Nov 2019 09:24:11 +0000 Subject: [PATCH 0001/1210] Typo --- README.md | 2 +- index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 6f06ea649..01a5d1eff 100644 --- a/README.md +++ b/README.md @@ -191,7 +191,7 @@ Iterator -------- ```python = iter() # `iter()` returns unmodified iterator. - = iter(, to_exclusive) # A Sequence of return values until 'to_exclusive'. + = iter(, to_exclusive) # A sequence of return values until 'to_exclusive'. = next( [, default]) # Raises StopIteration or returns 'default' on end. ``` diff --git a/index.html b/index.html index 957149e37..d2f8db4cf 100644 --- a/index.html +++ b/index.html @@ -341,7 +341,7 @@

#Iterator

<iter> = iter(<collection>)                 # `iter(<iter>)` returns unmodified iterator.
-<iter> = iter(<function>, to_exclusive)     # A Sequence of return values until 'to_exclusive'.
+<iter> = iter(<function>, to_exclusive)     # A sequence of return values until 'to_exclusive'.
 <el>   = next(<iter> [, default])           # Raises StopIteration or returns 'default' on end.
 
From 7db86add20455b94c71c517506fd6ede09f1ab35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Thu, 28 Nov 2019 00:50:16 +0100 Subject: [PATCH 0002/1210] Dict --- README.md | 5 +++-- index.html | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 01a5d1eff..5ffa0efde 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,6 @@ value = .setdefault(key, default=None) # Returns and writes default if ``` ```python -.update() = dict() # Creates a dict from coll. of key-value pairs. = dict(zip(keys, values)) # Creates a dict from two collections. = dict.fromkeys(keys [, value]) # Creates a dict from collection of keys. @@ -88,7 +87,9 @@ value = .setdefault(key, default=None) # Returns and writes default if ```python value = .pop(key) # Removes item or raises KeyError. -{k: v for k, v in .items() if k in keys} # Filters dictionary by keys. +.update() # Adds items. Replaces ones with matching keys. +[k for k, v in .items() if v == value] # Returns list of keys that point to value. +{k: v for k, v in .items() if k in keys} # Returns dictionary filtered by keys. ``` ### Counter diff --git a/index.html b/index.html index d2f8db4cf..4eff99dc4 100644 --- a/index.html +++ b/index.html @@ -266,13 +266,14 @@ <dict> = collections.defaultdict(<type>) # Creates a dict with default value of type. <dict> = collections.defaultdict(lambda: 1) # Creates a dict with default value 1. -
<dict>.update(<dict>)
-<dict> = dict(<collection>)                     # Creates a dict from coll. of key-value pairs.
+
<dict> = dict(<collection>)                     # Creates a dict from coll. of key-value pairs.
 <dict> = dict(zip(keys, values))                # Creates a dict from two collections.
 <dict> = dict.fromkeys(keys [, value])          # Creates a dict from collection of keys.
 
value = <dict>.pop(key)                         # Removes item or raises KeyError.
-{k: v for k, v in <dict>.items() if k in keys}  # Filters dictionary by keys.
+<dict>.update(<dict>)                           # Adds items. Replaces ones with matching keys.
+[k for k, v in <dict>.items() if v == value]    # Returns list of keys that point to value.
+{k: v for k, v in <dict>.items() if k in keys}  # Returns dictionary filtered by keys.
 

Counter

>>> from collections import Counter
 >>> colors = ['blue', 'red', 'blue', 'red', 'blue']

From 4f38a244ec192789f3128a4b6aa723d83091971d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?= 
Date: Thu, 28 Nov 2019 02:07:06 +0100
Subject: [PATCH 0003/1210] Iterator

---
 README.md  | 7 ++++---
 index.html | 6 +++---
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index 5ffa0efde..10ce7f59e 100644
--- a/README.md
+++ b/README.md
@@ -88,7 +88,7 @@ value  = .setdefault(key, default=None)   # Returns and writes default if
 ```python
 value = .pop(key)                         # Removes item or raises KeyError.
 .update()                           # Adds items. Replaces ones with matching keys.
-[k for k, v in .items() if v == value]    # Returns list of keys that point to value.
+[k for k, v in .items() if v == value]    # Returns list of keys that point to the value.
 {k: v for k, v in .items() if k in keys}  # Returns dictionary filtered by keys.
 ```
 
@@ -194,8 +194,10 @@ Iterator
  = iter()                 # `iter()` returns unmodified iterator.
  = iter(, to_exclusive)     # A sequence of return values until 'to_exclusive'.
    = next( [, default])           # Raises StopIteration or returns 'default' on end.
+ = list()                       # Returns a list of iterator's remaining elements.
 ```
 
+
 ### Itertools
 ```python
 from itertools import count, repeat, cycle, chain, islice
@@ -214,8 +216,7 @@ from itertools import count, repeat, cycle, chain, islice
 
 ```python
  = islice(, to_exclusive)
- = islice(, from_inclusive, to_exclusive)
- = islice(, from_inclusive, to_exclusive, +step_size)
+ = islice(, from_inclusive, to_exclusive [, +step_size])
 ```
 
 
diff --git a/index.html b/index.html
index 4eff99dc4..dc17109c1 100644
--- a/index.html
+++ b/index.html
@@ -272,7 +272,7 @@
 
value = <dict>.pop(key)                         # Removes item or raises KeyError.
 <dict>.update(<dict>)                           # Adds items. Replaces ones with matching keys.
-[k for k, v in <dict>.items() if v == value]    # Returns list of keys that point to value.
+[k for k, v in <dict>.items() if v == value]    # Returns list of keys that point to the value.
 {k: v for k, v in <dict>.items() if k in keys}  # Returns dictionary filtered by keys.
 

Counter

>>> from collections import Counter
@@ -344,6 +344,7 @@
 

#Iterator

<iter> = iter(<collection>)                 # `iter(<iter>)` returns unmodified iterator.
 <iter> = iter(<function>, to_exclusive)     # A sequence of return values until 'to_exclusive'.
 <el>   = next(<iter> [, default])           # Raises StopIteration or returns 'default' on end.
+<list> = list(<iter>)                       # Returns a list of iterator's remaining elements.
 

Itertools

from itertools import count, repeat, cycle, chain, islice
@@ -357,8 +358,7 @@
 <iter> = chain.from_iterable(<collection>)  # Empties collections inside a collection in order.
 
<iter> = islice(<collection>, to_exclusive)
-<iter> = islice(<collection>, from_inclusive, to_exclusive)
-<iter> = islice(<collection>, from_inclusive, to_exclusive, +step_size)
+<iter> = islice(<collection>, from_inclusive, to_exclusive [, +step_size])
 

#Generator

  • Any function that contains a yield statement returns a generator.
  • From 8ace934587301a82067cd71f2bcf5af18beeffc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 29 Nov 2019 06:05:09 +0100 Subject: [PATCH 0004/1210] String --- README.md | 7 ++++++- index.html | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 10ce7f59e..195a27893 100644 --- a/README.md +++ b/README.md @@ -320,9 +320,14 @@ String = .index() # Same but raises ValueError if missing. ``` +```python + = .isdecimal() # True if str contains only [0-9], [٠-٩], … + = .isdigit() # Also true if str contains '¹²³…'. + = .isnumeric() # Also true if str contains '¼½¾…'. +``` + ```python = .replace(old, new [, count]) # Replaces 'old' with 'new' at most 'count' times. - = .isnumeric() # True if str contains only numeric characters. = textwrap.wrap(, width) # Nicely breaks string into lines. ``` diff --git a/index.html b/index.html index dc17109c1..4544e5dc5 100644 --- a/index.html +++ b/index.html @@ -432,8 +432,11 @@ <int> = <str>.find(<sub_str>) # Returns start index of first match or -1. <int> = <str>.index(<sub_str>) # Same but raises ValueError if missing.
+
<bool> = <str>.isdecimal()                   # True if str contains only [0-9], [٠-٩], …
+<bool> = <str>.isdigit()                     # Also true if str contains '¹²³…'.
+<bool> = <str>.isnumeric()                   # Also true if str contains '¼½¾…'.
+
<str>  = <str>.replace(old, new [, count])   # Replaces 'old' with 'new' at most 'count' times.
-<bool> = <str>.isnumeric()                   # True if str contains only numeric characters.
 <list> = textwrap.wrap(<str>, width)         # Nicely breaks string into lines.