From 1f03065431f84ba1f47a51d989a108e3191b0d38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 22 Jun 2022 08:49:17 +0200 Subject: [PATCH] Format, Inline, Audio --- README.md | 16 ++++++++-------- index.html | 20 ++++++++++---------- pdf/remove_links.py | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 62ad69e..f203487 100644 --- a/README.md +++ b/README.md @@ -392,14 +392,14 @@ import re Format ------ ```python - = f'{}, {}' # Or: '{}, {}'.format(, ) + = f'{}, {}' # Curly brackets can also contain expressions. + = '{}, {}'.format(, ) # Or: '{0}, {a}'.format(, a=) = '%s, %s' % (, ) # Redundant and inferior C style formatting. ``` ### Attributes ```python ->>> from collections import namedtuple ->>> Person = namedtuple('Person', 'name height') +>>> Person = collections.namedtuple('Person', 'name height') >>> person = Person('Jean-Luc', 187) >>> f'{person.height}' '187' @@ -785,7 +785,7 @@ Inline ### Conditional Expression ```python - = if else + = if else # Only one expression gets evaluated. ``` ```python @@ -1814,7 +1814,7 @@ import csv = list() # Returns a list of remaining rows. ``` * **File must be opened with a `'newline=""'` argument, or newlines embedded inside quoted fields will not be interpreted correctly!** -* **To print the table to the console use [Tabulate](#table) library.** +* **To print the spreadsheet to the console use [Tabulate](#table) library.** * **For XML and binary Excel files (xlsx, xlsm and xlsb) use [Pandas](#dataframe-plot-encode-decode) library.** ### Write @@ -2920,9 +2920,9 @@ with wave.open('test.wav', 'rb') as file: ```python # $ pip3 install pyttsx3 import pyttsx3 -engine = pyttsx3.init() -engine.say('Sally sells seashells by the seashore.') -engine.runAndWait() + = pyttsx3.init() # Returns a new Engine. +.say() # Stages the string to be read. +.runAndWait() # Reads all staged strings while blocking. ``` diff --git a/index.html b/index.html index fea01b9..39a39a9 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -365,12 +365,12 @@ to_exclusive = <range>.stop
  • As shown above, it restricts all special sequence matches to the first 128 characters and prevents '\s' from accepting '[\x1c-\x1f]' (the so-called separator characters).
  • Use a capital letter for negation (all non-ASCII characters will be matched when used in combination with ASCII flag).
  • -

    #Format

    <str> = f'{<el_1>}, {<el_2>}'            # Or: '{}, {}'.format(<el_1>, <el_2>)
    +

    #Format

    <str> = f'{<el_1>}, {<el_2>}'            # Curly brackets can also contain expressions.
    +<str> = '{}, {}'.format(<el_1>, <el_2>)  # Or: '{0}, {a}'.format(<el_1>, a=<el_2>)
     <str> = '%s, %s' % (<el_1>, <el_2>)      # Redundant and inferior C style formatting.
     
    -

    Attributes

    >>> from collections import namedtuple
    ->>> Person = namedtuple('Person', 'name height')
    +

    Attributes

    >>> Person = collections.namedtuple('Person', 'name height')
     >>> person = Person('Jean-Luc', 187)
     >>> f'{person.height}'
     '187'
    @@ -673,7 +673,7 @@ func(*args, **kwargs)
     <bool> = all(<collection>)                                # Is True for all elements or empty.
     
    -

    Conditional Expression

    <obj> = <exp_if_true> if <condition> else <exp_if_false>
    +

    Conditional Expression

    <obj> = <exp_if_true> if <condition> else <exp_if_false>  # Only one expression gets evaluated.
     
    >>> [a if a else 'zero' for a in (0, 1, 2, 3)]
    @@ -1513,7 +1513,7 @@ CompletedProcess(args=['bc', 'newline=""' argument, or newlines embedded inside quoted fields will not be interpreted correctly!
    -
  • To print the table to the console use Tabulate library.
  • +
  • To print the spreadsheet to the console use Tabulate library.
  • For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library.
  • Write

    <writer> = csv.writer(<file>)       # Also: `dialect='excel', delimiter=','`.
    @@ -2379,9 +2379,9 @@ write_to_wav_file('test.wav', samples_f)
     
     

    Text to Speech

    # $ pip3 install pyttsx3
     import pyttsx3
    -engine = pyttsx3.init()
    -engine.say('Sally sells seashells by the seashore.')
    -engine.runAndWait()
    +<Engine> = pyttsx3.init()                       # Returns a new Engine.
    +<Engine>.say(<str>)                             # Stages the string to be read.
    +<Engine>.runAndWait()                           # Reads all staged strings while blocking.
     

    #Synthesizer

    Plays Popcorn by Gershon Kingsley:

    # $ pip3 install simpleaudio
    @@ -2901,7 +2901,7 @@ $ pyinstaller script.py --add-data '<path>:.'  
      
     
       
     
    diff --git a/pdf/remove_links.py b/pdf/remove_links.py
    index 92bed96..96e31ae 100755
    --- a/pdf/remove_links.py
    +++ b/pdf/remove_links.py
    @@ -17,7 +17,7 @@ MATCHES = {
         'Generators returned by the generator functions and generator expressions.': 'Generators returned by the generator functions (p. 4) and generator expressions (p. 11).',
         'File objects returned by the open() function, etc.': 'File objects returned by the open() function (p. 22), etc.',
         'Functions report OS related errors by raising either OSError or one of its subclasses.': 'Functions report OS related errors by raising OSError or one of its subclasses (p. 23).',
    -    'To print the table to the console use Tabulate library.': 'To print the table to the console use Tabulate library (p. 34).',
    +    'To print the spreadsheet to the console use Tabulate library.': 'To print the spreadsheet to the console use Tabulate library (p. 34).',
         'For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library.': 'For XML and binary Excel files (xlsx, xlsm and xlsb) use Pandas library (p. 46).',
         'Bools will be stored and returned as ints and dates as ISO formatted strings.': 'Bools will be stored and returned as ints and dates as ISO formatted strings (p. 9).',
         'An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. All arguments must be pickable.': 'An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. All arguments must be pickable (p. 25).',