From edac4bb3f631af09f4ac54c838985ef3b198cab0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jure=20=C5=A0orn?= Module of functions that provide the functionality of operators.#Operator
import operator as op
<obj> = op.add/sub/mul/truediv/floordiv/mod(<obj>, <obj>) # +, -, *, /, //, %
@@ -1927,10 +1927,9 @@ W, H = 15, 7
async def human_controller(screen, moves):
while True:
- ch = screen.getch()
key_mappings = {258: D.s, 259: D.n, 260: D.w, 261: D.e}
- if ch in key_mappings:
- moves.put_nowait(('*', key_mappings[ch]))
+ if d := key_mappings.get(screen.getch()):
+ moves.put_nowait(('*', d))
await asyncio.sleep(0.005)
async def model(moves, state):
@@ -1948,6 +1947,7 @@ W, H = 15, 7
for id_, p in state.items():
screen.addstr(offset.y + (p.y - state['*'].y + H//2) % H,
offset.x + (p.x - state['*'].x + W//2) % W, str(id_))
+ screen.refresh()
await asyncio.sleep(0.005)
if __name__ == '__main__':
@@ -2442,7 +2442,7 @@ rect = pg.Rect(240, 2
deltas = {pg.K_UP: (0, -20), pg.K_RIGHT: (20, 0), pg.K_DOWN: (0, 20), pg.K_LEFT: (-20, 0)}
for event in pg.event.get(pg.KEYDOWN):
dx, dy = deltas.get(event.key, (0, 0))
- rect.move_ip((dx, dy))
+ rect = rect.move((dx, dy))
screen.fill((0, 0, 0))
pg.draw.rect(screen, (255, 255, 255), rect)
pg.display.flip()
@@ -2464,7 +2464,7 @@ rect = pg.Rect(240, 2
<Surf> = pg.Surface((width, height)) # New RGB surface. RGBA if `flags=pg.SRCALPHA`.
<Surf> = pg.image.load(<path/file>) # Loads the image. Format depends on source.
<Surf> = pg.surfarray.make_surface(<np_array>) # Also `<np_arr> = surfarray.pixels3d(<Surf>)`.
-<Surf> = <Surf>.subsurface(<Rect>) # Returns a subsurface.
+<Surf> = <Surf>.subsurface(<Rect>) # Creates a new surface from the cutout.
<el> = <Sr>[key/index] # Or: <Sr>.key
<Sr> = <Sr>[keys/indexes] # Or: <Sr>[<keys_slice/slice>]
-<Sr> = <Sr>[bools] # Or: <Sr>.i/loc[bools]
+<Sr> = <Sr>[bools] # Or: <Sr>.loc/iloc[bools]
<Sr> = <Sr> ><== <el/Sr> # Returns a Series of bools.
<Sr> = <Sr> +-*/ <el/Sr> # Items with non-matching keys get value NaN.
@@ -2934,7 +2934,7 @@ $ pyinstaller script.py --add-data '<path>:.'
diff --git a/parse.js b/parse.js
index c958588..93d9630 100755
--- a/parse.js
+++ b/parse.js
@@ -137,10 +137,9 @@ const COROUTINES =
'\n' +
'async def human_controller(screen, moves):\n' +
' while True:\n' +
- ' ch = screen.getch()\n' +
' key_mappings = {258: D.s, 259: D.n, 260: D.w, 261: D.e}\n' +
- ' if ch in key_mappings:\n' +
- ' moves.put_nowait((\'*\', key_mappings[ch]))\n' +
+ ' if d := key_mappings.get(screen.getch()):\n' +
+ ' moves.put_nowait((\'*\', d))\n' +
' await asyncio.sleep(0.005)\n' +
'\n' +
'async def model(moves, state):\n' +
@@ -158,6 +157,7 @@ const COROUTINES =
' for id_, p in state.items():\n' +
' screen.addstr(offset.y + (p.y - state[\'*\'].y + H//2) % H,\n' +
' offset.x + (p.x - state[\'*\'].x + W//2) % W, str(id_))\n' +
+ ' screen.refresh()\n' +
' await asyncio.sleep(0.005)\n' +
'\n' +
'if __name__ == \'__main__\':\n' +
diff --git a/pdf/index_for_pdf.html b/pdf/index_for_pdf.html
index 9b80128..70fbdb6 100644
--- a/pdf/index_for_pdf.html
+++ b/pdf/index_for_pdf.html
@@ -133,7 +133,7 @@
super function, 14
sys module, 13, 21-22
table, 26, 27, 34, 37-38, 45-46
+
table, 26, 27, 34, 37-38, 45-46
template, 6, 36
threading module, 30
time module, 34, 36
diff --git a/pdf/remove_links.py b/pdf/remove_links.py
index ba44974..3134eb3 100755
--- a/pdf/remove_links.py
+++ b/pdf/remove_links.py
@@ -22,7 +22,7 @@ MATCHES = {
'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).',
+ 'An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments/results must be pickable.': 'An object with the same interface called ProcessPoolExecutor provides true parallelism by running a separate interpreter in each process. Arguments/results must be pickable.',
'Asyncio module also provides its own Queue, Event, Lock and Semaphore classes.': 'Asyncio module also provides its own Queue, Event, Lock and Semaphore classes (p. 30).',
'A WSGI server like Waitress and a HTTP server such as Nginx are needed to run globally.': 'A WSGI server like Waitress and a HTTP server such as Nginx are needed to run globally.',
'The "latest and greatest" profiler that can also monitor GPU usage is called Scalene.': 'The "latest and greatest" profiler that can also monitor GPU usage is called Scalene.',