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
***Method iter() is required for `'isinstance(<obj>, abc.Iterable)'` to return True, however any object with getitem() will work with any code expecting an iterable.**
***Names of their required methods are stored in `'<abc>.__abstractmethods__'`.**
1330
+
***MutableSequence, Set, MutableSet, Mapping and MutableMapping ABCs are also extendable. Use `'<abc>.__abstractmethods__'` to get names of required methods.**
1332
1331
1333
1332
1334
1333
Enum
@@ -2161,7 +2160,7 @@ with <lock>: # Enters the block by calling acq
2161
2160
<bool>=<Future>.cancel() # Cancels or returns False if running/finished.
2162
2161
<iter>= as_completed(<coll_of_Futures>) # `next(<iter>)` returns next completed Future.
2163
2162
```
2164
-
***Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As\_completed() fails if next() is called too late, even if all threads have finished.**
2163
+
***Map() and as\_completed() also accept 'timeout'. It causes futures.TimeoutError when next() is called/blocking. Map() times from original call and as_completed() from first call to next(). As\_completed() fails if next() is called too late, even if all threads are done.**
2165
2164
***Exceptions that happen inside threads are raised when map iterator's next() or Future's result() are called. Future's exception() method returns exception object or None.**
2166
2165
***ProcessPoolExecutor provides true parallelism but: everything sent to/from workers must be [pickable](#pickle), queues must be sent using executor's 'initargs' and 'initializer' parameters, and executor should only be reachable via `'if __name__ == "__main__": ...'`.**
2167
2166
@@ -2245,9 +2244,9 @@ import logging as log
2245
2244
2246
2245
```python
2247
2246
log.basicConfig(filename=<path>, level='DEBUG') # Configures the root logger (see Setup).
2248
-
log.debug/info/warning/error/critical(<str>) #Logs to the root logger.
2249
-
<Logger>= log.getLogger(__name__) #Logger named after the module.
2250
-
<Logger>.<level>(<str>) #Logs to the logger.
2247
+
log.debug/info/warning/error/critical(<str>) #Sends message to the root logger.
2248
+
<Logger>= log.getLogger(__name__) #Returns logger named after the module.
2249
+
<Logger>.<level>(<str>) #Sends message to the logger.
2251
2250
<Logger>.exception(<str>) # Error() that appends caught exception.
2252
2251
```
2253
2252
@@ -2321,17 +2320,17 @@ Coroutines
2321
2320
----------
2322
2321
***Coroutines have a lot in common with threads, but unlike threads, they only give up control when they call another coroutine and they don’t use as much memory.**
2323
2322
***Coroutine definition starts with `'async'` and its call with `'await'`.**
2324
-
***`'asyncio.run(<coroutine>)'`is the main entry point for asynchronous programs.**
2323
+
***Use `'asyncio.run(<coroutine>)'`to start the first/main coroutine.**
2325
2324
2326
2325
```python
2327
2326
import asyncio as aio
2328
2327
```
2329
2328
2330
2329
```python
2331
2330
<coro>=<async_function>(<args>) # Creates a coroutine by calling async def function.
2332
-
<obj>=await<coroutine># Starts the coroutine and returns result.
2331
+
<obj>=await<coroutine># Starts the coroutine and returns its result.
2333
2332
<task>= aio.create_task(<coroutine>) # Schedules the coroutine for execution.
2334
-
<obj>=await<task># Returns result. Also <task>.cancel().
2333
+
<obj>=await<task># Returns coroutine's result. Also <task>.cancel().
2335
2334
```
2336
2335
2337
2336
```python
@@ -2355,7 +2354,7 @@ def main(screen):
2355
2354
2356
2355
asyncdefmain_coroutine(screen):
2357
2356
moves = asyncio.Queue()
2358
-
state = {'*': P(0, 0), **{id_: P(W//2, H//2) for id_ inrange(10)}}
2357
+
state = {'*': P(0, 0)} |{id_: P(W//2, H//2) for id_ inrange(10)}
2359
2358
ai = [random_controller(id_, moves) for id_ inrange(10)]
***Starts the app at `'http://localhost:5000'`. Use `'host="0.0.0.0"'` to run externally.**
2560
2559
***Install a WSGI server like [Waitress](https://flask.palletsprojects.com/en/latest/deploying/waitress/) and a HTTP server such as [Nginx](https://flask.palletsprojects.com/en/latest/deploying/nginx/) for better security.**
0 commit comments