You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+22-21Lines changed: 22 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1884,15 +1884,15 @@ import sqlite3
1884
1884
1885
1885
### Read
1886
1886
```python
1887
-
<cursor>=<conn>.execute('<query>') # Can raise a subclass of the sqlite3.Error.
1887
+
<cursor>=<conn>.execute('<query>') # Can raise a subclass of the `sqlite3.Error`.
1888
1888
<tuple>=<cursor>.fetchone() # Returns the next row. Also next(<cursor>).
1889
1889
<list>=<cursor>.fetchall() # Returns remaining rows. Also list(<cursor>).
1890
1890
```
1891
1891
1892
1892
### Write
1893
1893
```python
1894
-
<conn>.execute('<query>') # Can raise a subclass of the sqlite3.Error.
1895
-
<conn>.commit() # Saves all changes since the last commit.
1894
+
<conn>.execute('<query>') # Can raise a subclass of the `sqlite3.Error`.
1895
+
<conn>.commit() # Saves all the changes since the last commit.
1896
1896
<conn>.rollback() # Discards all changes since the last commit.
1897
1897
```
1898
1898
@@ -1904,7 +1904,7 @@ with <conn>: # Exits the block with commit() o
1904
1904
1905
1905
### Placeholders
1906
1906
```python
1907
-
<conn>.execute('<query>', <list/tuple>) # Replaces every question mark with an item.
1907
+
<conn>.execute('<query>', <list/tuple>) # Replaces every question mark with its item.
1908
1908
<conn>.execute('<query>', <dict/namedtuple>) # Replaces every :<key> with a matching value.
1909
1909
<conn>.executemany('<query>', <coll_of_coll>) # Executes the query once for each collection.
1910
1910
```
@@ -1922,7 +1922,7 @@ with <conn>: # Exits the block with commit() o
1922
1922
```
1923
1923
1924
1924
### SQLAlchemy
1925
-
**Library for interacting with various DB systems via SQL, method chaining, or ORM.**
1925
+
**Library for interacting with various DB systems via SQL, [method chaining](https://docs.sqlalchemy.org/en/latest/tutorial/data_select.html#the-select-sql-expression-construct) or [ORM](https://docs.sqlalchemy.org/en/latest/orm/quickstart.html#simple-select).**
1926
1926
```python
1927
1927
# $ pip3 install sqlalchemy
1928
1928
from sqlalchemy import create_engine, text
@@ -1946,31 +1946,32 @@ with <conn>.begin(): ... # Exits the block with a commit o
1946
1946
1947
1947
Bytes
1948
1948
-----
1949
-
**Immutable sequence of single bytes. Mutable version is called bytearray.**
1949
+
**An immutable sequence of single bytes. Mutable version is called bytearray.**
1950
1950
1951
1951
```python
1952
-
<bytes>=b'<str>'# Only accepts ASCII chars and [\x00-\xff].
1953
-
<int>=<bytes>[index] # Returns an integer in range from 0 to 255.
1954
-
<bytes>=<bytes>[<slice>] # Returns bytes even if it has one element.
1955
-
<bytes>=<bytes>.join(<coll_of_bytes>) # Joins elements using bytes as a separator.
1952
+
<bytes>=b'<str>'# Accepts ASCII characters and \x00 to \xff.
1953
+
<int>=<bytes>[index] # Returns the byte as int between 0 and 255.
1954
+
<bytes>=<bytes>[<slice>] # Returns bytes even if it has one element.
1955
+
<bytes>=<bytes>.join(<coll_of_bytes>) # Joins elements using bytes as a separator.
1956
1956
```
1957
1957
1958
1958
### Encode
1959
1959
```python
1960
-
<bytes>=bytes(<coll_of_ints>) # Integers must be in range from 0 to 255.
1961
-
<bytes>=bytes(<str>, 'utf-8') # Encodes the string. Also <str>.encode().
1962
-
<bytes>=bytes.fromhex('<hex>') # Hex pairs can be separated by whitespace.
<mapping_patt>= {<value_pattern>: <patt>, ...} # Matches a dict if it has matching items.
2143
2144
<class_pattern>=<type>(<attr_name>=<patt>, ...) # Matches object that has matching attrbs.
2144
2145
```
2145
-
***Sequence pattern can also be written as a tuple, either with or without the brackets.**
2146
+
***The sequence pattern can also be written as a tuple, either with or without the brackets.**
2146
2147
***Use `'*<name>'` and `'**<name>'` in sequence/mapping patterns to bind remaining items.**
2147
2148
***Sequence pattern must match all items of the collection, while mapping pattern does not.**
2148
2149
***Patterns can be surrounded with brackets to override their precedence: `'|'` > `'as'` > `','`. For example, `'[1, 2]'` is matched by the `'case 1|2, 2|3 as x if x == 2:'` block.**
@@ -2562,7 +2563,7 @@ def serve_html(sport):
2562
2563
***`'fl.render_template(filename, <kwargs>)'` renders a file located in 'templates' dir.**
2563
2564
***`'fl.abort(<int>)'` returns error code and `'return fl.redirect(<url>)'` redirects.**
2564
2565
***`'fl.request.args[<str>]'` returns parameter from query string (URL part right of '?').**
2565
-
***`'fl.session[<str>] = <obj>'` stores session data. It requires secret key to be set at the startup with `'app.secret_key = <str>'`.**
2566
+
***`'fl.session[<str>] = <obj>'` stores session data and `'fl.session.clear()'` clears it. A session cookie key needs to be set at the startup with `'app.secret_key = <str>'`.**
2566
2567
2567
2568
### Serving JSON
2568
2569
```python
@@ -2783,7 +2784,7 @@ from PIL import Image
2783
2784
```
2784
2785
2785
2786
### Modes
2786
-
***`'L'` - Lightness (greyscale image). Each pixel is an integer between 0 and 255.**
2787
+
***`'L'` - Lightness (greyscale image). Each pixel is stored as an int between 0 and 255.**
2787
2788
***`'RGB'` - Red, green, blue (true color image). Each pixel is a tuple of three integers.**
2788
2789
***`'RGBA'` - RGB with alpha. Low alpha (i.e. fourth int) makes pixel more transparent.**
2789
2790
***`'HSV'` - Hue, saturation, value. Three ints representing color in HSV color space.**
0 commit comments