diff --git a/README.md b/README.md index 5b0f587..cc9d2b4 100644 --- a/README.md +++ b/README.md @@ -396,14 +396,12 @@ Format = '%s, %s' % (, ) # Redundant and inferior C-style formatting. ``` -### Attributes +### Example ```python >>> Person = collections.namedtuple('Person', 'name height') >>> person = Person('Jean-Luc', 187) ->>> f'{person.height}' -'187' ->>> '{p.height}'.format(p=person) -'187' +>>> f'{person.name} is {person.height / 100} meters tall.' +'Jean-Luc is 1.87 meters tall.' ``` ### General Options @@ -415,7 +413,8 @@ Format {:0} # '' ``` * **Options can be generated dynamically: `f'{:{}[…]}'`.** -* **Adding `'!r'` before the colon converts object to string by calling its [repr()](#class) method.** +* **Adding `'='` to the expression prepends it to the output: `f'{1+1=}'` returns `'1+1=2'`.** +* **Adding `'!r'` to the expression converts object to string by calling its [repr()](#class) method.** ### Strings ```python diff --git a/index.html b/index.html index b46d1b9..1c39d24 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -369,12 +369,10 @@ Point(x=1, y=2 <str> = '%s, %s' % (<el_1>, <el_2>) # Redundant and inferior C-style formatting. -

Attributes

>>> Person = collections.namedtuple('Person', 'name height')
+

Example

>>> Person = collections.namedtuple('Person', 'name height')
 >>> person = Person('Jean-Luc', 187)
->>> f'{person.height}'
-'187'
->>> '{p.height}'.format(p=person)
-'187'
+>>> f'{person.name} is {person.height / 100} meters tall.'
+'Jean-Luc is 1.87 meters tall.'
 

General Options

{<el>:<10}                               # '<el>      '
@@ -386,7 +384,8 @@ Point(x=1, y=2
 
 
  • Options can be generated dynamically: f'{<el>:{<str/int>}[…]}'.
  • -
  • Adding '!r' before the colon converts object to string by calling its repr() method.
  • +
  • Adding '=' to the expression prepends it to the output: f'{1+1=}' returns '1+1=2'.
  • +
  • Adding '!r' to the expression converts object to string by calling its repr() method.

Strings

{'abcde':10}                             # 'abcde     '
 {'abcde':10.3}                           # 'abc       '
@@ -1593,7 +1592,7 @@ CompletedProcess(args=['bc', ISO formatted strings.
 
-

Example

Values are not actually saved in this example because 'conn.commit()' is omitted!

>>> conn = sqlite3.connect('test.db')
+

Example

Values are not actually saved in this example because 'conn.commit()' is omitted!

>>> conn = sqlite3.connect('test.db')
 >>> conn.execute('CREATE TABLE person (person_id INTEGER PRIMARY KEY, name, height)')
 >>> conn.execute('INSERT INTO person VALUES (NULL, ?, ?)', ('Jean-Luc', 187)).lastrowid
 1
@@ -1811,7 +1810,7 @@ first_element    = op.methodcaller('pop', 

Attributes

<list> = dir(<object>)                     # Names of object's attributes (incl. methods).
+

Attributes

<list> = dir(<object>)                     # Names of object's attributes (incl. methods).
 <dict> = vars(<object>)                    # Dict of writable attributes. Also <obj>.__dict__.
 <bool> = hasattr(<object>, '<attr_name>')  # Checks if getattr() raises an AttributeError.
 value  = getattr(<object>, '<attr_name>')  # Raises AttributeError if attribute is missing.
@@ -2226,7 +2225,7 @@ right = [[0.1,  0.60.1,  0.6,  0.8]]
 
-

Example

For each point returns index of its nearest point ([0.1, 0.6, 0.8] => [1, 2, 1]):

>>> points = np.array([0.1, 0.6, 0.8])
+

Example

For each point returns index of its nearest point ([0.1, 0.6, 0.8] => [1, 2, 1]):

>>> points = np.array([0.1, 0.6, 0.8])
  [ 0.1,  0.6,  0.8]
 >>> wrapped_points = points.reshape(3, 1)
 [[ 0.1],
@@ -2935,7 +2934,7 @@ $ pyinstaller script.py --add-data '<path>:.'  
  
 
   
 
diff --git a/pdf/remove_links.py b/pdf/remove_links.py
index 6edf503..ba44974 100755
--- a/pdf/remove_links.py
+++ b/pdf/remove_links.py
@@ -9,7 +9,7 @@ from pathlib import Path
 MATCHES = {
     'For details about sorted(), min() and max() see sortable.': 'For details about sorted(), min() and max() see sortable (p. 16).',
     'Module operator provides functions itemgetter() and mul() that offer the same functionality as lambda expressions above.': 'Module \'operator\' (p. 31) provides functions itemgetter() and mul() that offer the same functionality as lambda expressions (p. 11) above.',
-    'Adding \'!r\' before the colon converts object to string by calling its repr() method.': 'Adding \'!r\' before the colon converts object to string by calling its repr() method (p. 14).',
+    'Adding \'!r\' to the expression converts object to string by calling its repr() method.': 'Adding \'!r\' to the expression converts object to string by calling its repr() method (p. 14).',
     'It can be any callable, but is usually implemented as a function that returns a closure.': 'It can be any callable, but is usually implemented as a function that returns a closure.',
     'Objects can be made sortable with \'order=True\' and immutable with \'frozen=True\'.': 'Objects can be made sortable with \'order=True\' and immutable with \'frozen=True\'.',
     'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.': 'For object to be hashable, all attributes must be hashable and \'frozen\' must be True.',