diff --git a/README.md b/README.md index c591e9a..bebfeb4 100644 --- a/README.md +++ b/README.md @@ -2104,7 +2104,7 @@ from concurrent.futures import ThreadPoolExecutor, as_completed ``` * **Use `'kwargs='` to pass keyword arguments to the function.** * **Use `'daemon=True'`, or the program will not be able to exit while the thread is alive.** -* **To delay thread execution use `'Timer(, )'` instead of Thread().** +* **To delay thread execution use `'Timer(seconds, )'` instead of Thread().** ### Lock ```python @@ -2137,16 +2137,16 @@ with : # Enters the block by calling acq ### Thread Pool Executor ```python - = ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as : …` + = ThreadPoolExecutor(max_workers=None) # Or: `with ThreadPoolExecutor() as : ...` = .map(, , ...) # Multithreaded and non-lazy map(). Keeps order. = .submit(, , ...) # Creates a thread and returns its Future obj. -.shutdown(wait=True) # Blocks until all threads finish executing. +.shutdown() # Blocks until all threads finish executing. ``` ```python = .done() # Checks if the thread has finished executing. = .result(timeout=None) # Waits for thread to finish and returns result. - = .cancel() # Returns False if thread is already running. + = .cancel() # Cancels or returns False if running/finished. = as_completed() # Each Future is yielded as it completes. ``` * **Map() and as_completed() also accept 'timeout' argument that causes TimeoutError if result isn't available in 'timeout' seconds after next() is called.** @@ -2159,13 +2159,13 @@ Operator **Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.** ```python import operator as op - = op.not_() # or, and (both missing), not - = op.eq/ne/lt/le/gt/ge/contains/is_(, ) # ==, !=, <, <=, >, >=, in, is - = op.or_/xor/and_(, ) # |, ^, & - = op.add/sub/mul/truediv/floordiv/mod(, ) # +, -, *, /, //, % - = op.neg/invert() # -, ~ - = op.pow(, ) # ** - = op.itemgetter/attrgetter/methodcaller( [, ...]) # [index/key], .name, .name() + = op.not_() # not (or/and bind even less) + = op.eq/ne/lt/le/gt/ge/contains/is_(, ) # ==, !=, <, <=, >, >=, in, is + = op.or_/xor/and_(, ) # |, ^, & + = op.add/sub/mul/truediv/floordiv/mod(, ) # +, -, *, /, //, % + = op.neg/invert() # -, ~ + = op.pow(, ) # ** + = op.itemgetter/attrgetter/methodcaller( [, ...]) # [index/key], .name, .name() ``` ```python @@ -2920,7 +2920,7 @@ samples_f = (sin(i * 2 * pi * 440 / 44100) for i in range(100_000)) write_to_wav_file('test.wav', samples_f) ``` -#### Adds noise to a mono WAV file: +#### Adds noise to the mono WAV file: ```python from random import random add_noise = lambda value: value + (random() - 0.5) * 0.03 @@ -2928,14 +2928,14 @@ samples_f = (add_noise(f) for f in read_wav_file('test.wav')) write_to_wav_file('test.wav', samples_f) ``` -#### Plays a WAV file: +#### Plays the WAV file: ```python # $ pip3 install simpleaudio from simpleaudio import play_buffer with wave.open('test.wav', 'rb') as file: p = file.getparams() frames = file.readframes(-1) - play_buffer(frames, p.nchannels, p.sampwidth, p.framerate) + play_buffer(frames, p.nchannels, p.sampwidth, p.framerate).wait_done() ``` ### Text to Speech @@ -3043,7 +3043,7 @@ rect(, color, , width=0) # Also polygon(, color, po ### Sound ```python - = pg.mixer.Sound() # Loads WAV file or array of signed shorts. + = pg.mixer.Sound() # WAV file or bytes/array of signed shorts. .play/stop() # Also .set_volume(). ``` diff --git a/index.html b/index.html index 91acd37..3dbbc23 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1741,7 +1741,7 @@ CompletedProcess(args=['bc', 'kwargs=<dict>' to pass keyword arguments to the function.
  • Use 'daemon=True', or the program will not be able to exit while the thread is alive.
  • -
  • To delay thread execution use 'Timer(<float>, <func>)' instead of Thread().
  • +
  • To delay thread execution use 'Timer(seconds, <func>)' instead of Thread().
  • Lock

    <lock> = RLock()                               # Lock that can only be released by acquirer.
     <lock>.acquire()                               # Waits for the lock to be available.
    @@ -1764,15 +1764,15 @@ CompletedProcess(args=['bc', # Raises queue.Empty exception if empty.
     
    -

    Thread Pool Executor

    <Exec> = ThreadPoolExecutor(max_workers=None)  # Or: `with ThreadPoolExecutor() as <name>: …`
    +

    Thread Pool Executor

    <Exec> = ThreadPoolExecutor(max_workers=None)  # Or: `with ThreadPoolExecutor() as <name>: ...`
     <iter> = <Exec>.map(<func>, <args_1>, ...)     # Multithreaded and non-lazy map(). Keeps order.
     <Futr> = <Exec>.submit(<func>, <arg_1>, ...)   # Creates a thread and returns its Future obj.
    -<Exec>.shutdown(wait=True)                     # Blocks until all threads finish executing.
    +<Exec>.shutdown()                              # Blocks until all threads finish executing.
     
    <bool> = <Future>.done()                       # Checks if the thread has finished executing.
     <obj>  = <Future>.result(timeout=None)         # Waits for thread to finish and returns result.
    -<bool> = <Future>.cancel()                     # Returns False if thread is already running.
    +<bool> = <Future>.cancel()                     # Cancels or returns False if running/finished.
     <iter> = as_completed(<coll_of_Futures>)       # Each Future is yielded as it completes.
     
      @@ -1781,13 +1781,13 @@ CompletedProcess(args=['bc', pickable. Queues must be sent using executor's 'initargs' and 'initializer' parameters.

    #Operator

    Module of functions that provide the functionality of operators. Functions are ordered by operator precedence, starting with least binding.

    import operator as op
    -<bool> = op.not_(<obj>)                                        # or, and (both missing), not
    -<bool> = op.eq/ne/lt/le/gt/ge/contains/is_(<obj>, <obj>)       # ==, !=, <, <=, >, >=, in, is
    -<obj>  = op.or_/xor/and_(<int/set>, <int/set>)                 # |, ^, &
    -<obj>  = op.add/sub/mul/truediv/floordiv/mod(<obj>, <obj>)     # +, -, *, /, //, %
    -<num>  = op.neg/invert(<num>)                                  # -, ~
    -<num>  = op.pow(<num>, <num>)                                  # **
    -<func> = op.itemgetter/attrgetter/methodcaller(<obj> [, ...])  # [index/key], .name, .name()
    +<bool> = op.not_(<obj>)                                         # not (or/and bind even less)
    +<bool> = op.eq/ne/lt/le/gt/ge/contains/is_(<obj>, <obj>)        # ==, !=, <, <=, >, >=, in, is
    +<obj>  = op.or_/xor/and_(<int/set>, <int/set>)                  # |, ^, &
    +<obj>  = op.add/sub/mul/truediv/floordiv/mod(<obj>, <obj>)      # +, -, *, /, //, %
    +<num>  = op.neg/invert(<num>)                                   # -, ~
    +<num>  = op.pow(<num>, <num>)                                   # **
    +<func> = op.itemgetter/attrgetter/methodcaller(<obj> [, ...])   # [index/key], .name, .name()
     
    @@ -2389,18 +2389,18 @@ write_to_wav_file('test.wav', samples_f)
    -

    Adds noise to a mono WAV file:

    from random import random
    +

    Adds noise to the mono WAV file:

    from random import random
     add_noise = lambda value: value + (random() - 0.5) * 0.03
     samples_f = (add_noise(f) for f in read_wav_file('test.wav'))
     write_to_wav_file('test.wav', samples_f)
     
    -

    Plays a WAV file:

    # $ pip3 install simpleaudio
    +

    Plays the WAV file:

    # $ pip3 install simpleaudio
     from simpleaudio import play_buffer
     with wave.open('test.wav', 'rb') as file:
         p = file.getparams()
         frames = file.readframes(-1)
    -    play_buffer(frames, p.nchannels, p.sampwidth, p.framerate)
    +    play_buffer(frames, p.nchannels, p.sampwidth, p.framerate).wait_done()
     

    Text to Speech

    # $ pip3 install pyttsx3
    @@ -2482,7 +2482,7 @@ rect(<Surf>, color, <Rect>, width=0
     <Surf> = <Font>.render(text, antialias, color)  # Background color can be specified at the end.
     
    -

    Sound

    <Sound> = pg.mixer.Sound(<path/file/bytes>)     # Loads WAV file or array of signed shorts.
    +

    Sound

    <Sound> = pg.mixer.Sound(<path/file/bytes>)     # WAV file or bytes/array of signed shorts.
     <Sound>.play/stop()                             # Also <Sound>.set_volume(<float>).
     
    @@ -2928,7 +2928,7 @@ $ deactivate # Deactivates the activ