@@ -599,7 +599,7 @@ from dateutil.tz import UTC, tzlocal, gettz, datetime_exists, resolve_imaginary
599599```
600600* ** Use ` '<D/DT>.weekday()' ` to get the day of the week (Mon == 0).**
601601* ** ` 'fold=1' ` means the second pass in case of time jumping back for one hour.**
602- * ** ` '<DTa> = resolve_imaginary(<DTa>)' ` fixes DTs that fall into missing hour.**
602+ * ** ` '<DTa> = resolve_imaginary(<DTa>)' ` fixes DTs that fall into the missing hour.**
603603
604604### Now
605605``` python
@@ -731,10 +731,10 @@ def f(x, *args, z, **kwargs): # f(x=1, y=2, z=3) | f(1, y=2, z=3) | f(1, 2, z=3
731731
732732### Other Uses
733733``` python
734- < list > = [* < collection> [, ... ]]
735- < set > = {* < collection> [, ... ]}
736- < tuple > = (* < collection> , [... ])
737- < dict > = {** < dict > [, ... ]}
734+ < list > = [* < collection> [, ... ]]
735+ < set > = {* < collection> [, ... ]}
736+ < tup. > = (* < collection> , [... ])
737+ < dict > = {** < dict > [, ... ]}
738738```
739739
740740``` python
@@ -746,48 +746,40 @@ Inline
746746------
747747### Lambda
748748``` python
749- < function > = lambda : < return_value>
750- < function > = lambda <argument_1 >, <argument_2 >: < return_value>
749+ < func > = lambda : < return_value>
750+ < func > = lambda <arg_1 >, <arg_2 >: < return_value>
751751```
752752
753753### Comprehensions
754754``` python
755- < list > = [i+ 1 for i in range (10 )] # [1, 2, ..., 10]
756- < set > = {i for i in range (10 ) if i > 5 } # {6, 7, 8, 9}
757- < iter > = (i+ 5 for i in range (10 )) # (5, 6, ..., 14)
758- < dict > = {i: i* 2 for i in range (10 )} # {0: 0, 1: 2, ..., 9: 18}
755+ < list > = [i+ 1 for i in range (10 )] # [1, 2, ..., 10]
756+ < set > = {i for i in range (10 ) if i > 5 } # {6, 7, 8, 9}
757+ < iter > = (i+ 5 for i in range (10 )) # (5, 6, ..., 14)
758+ < dict > = {i: i* 2 for i in range (10 )} # {0: 0, 1: 2, ..., 9: 18}
759759```
760760
761761``` python
762- out = [i+ j for i in range (10 ) for j in range (10 )]
763- ```
764-
765- #### Is the same as:
766- ``` python
767- out = []
768- for i in range (10 ):
769- for j in range (10 ):
770- out.append(i+ j)
762+ >> > [l+ r for l in ' abc' for r in ' abc' ]
763+ [' aa' , ' ab' , ' ac' , ... , ' cc' ]
771764```
772765
773766### Map, Filter, Reduce
774767``` python
775- from functools import reduce
776-
777- < iter > = map (lambda x : x + 1 , range (10 )) # (1, 2, ..., 10)
778- < iter > = filter (lambda x : x > 5 , range (10 )) # (6, 7, 8, 9)
779- < obj> = reduce (lambda out , x : out + x, range (10 )) # 45
768+ < iter > = map (lambda x : x + 1 , range (10 )) # (1, 2, ..., 10)
769+ < iter > = filter (lambda x : x > 5 , range (10 )) # (6, 7, 8, 9)
770+ < obj> = reduce (lambda out , x : out + x, range (10 )) # 45
780771```
772+ * ** Reduce must be imported from functools module.**
781773
782774### Any, All
783775``` python
784- < bool > = any (< collection> ) # False if empty.
785- < bool > = all (el[1 ] for el in < collection> ) # True if empty.
776+ < bool > = any (< collection> ) # False if empty.
777+ < bool > = all (el[1 ] for el in < collection> ) # True if empty.
786778```
787779
788- ### If - Else
780+ ### Conditional Expression
789781``` python
790- < obj> = < expression_if_true > if < condition> else < expression_if_false >
782+ < obj> = < exp_if_true > if < condition> else < exp_if_false >
791783```
792784
793785``` python
@@ -810,7 +802,7 @@ direction = Direction.n
810802
811803``` python
812804from dataclasses import make_dataclass
813- Creature = make_dataclass(' Creature' , [' location ' , ' direction ' ])
805+ Creature = make_dataclass(' Creature' , [' loc ' , ' dir ' ])
814806creature = Creature(Point(0 , 0 ), Direction.n)
815807```
816808
@@ -1950,13 +1942,14 @@ Struct
19501942
19511943``` python
19521944from struct import pack, unpack, iter_unpack
1945+ ```
19531946
1947+ ``` python
19541948< bytes > = pack(' <format>' , < num_1> [, < num_2> , ... ])
19551949< tuple > = unpack(' <format>' , < bytes > )
19561950< tuples> = iter_unpack(' <format>' , < bytes > )
19571951```
19581952
1959- ### Example
19601953``` python
19611954>> > pack(' >hhl' , 1 , 2 , 3 )
19621955b ' \x00\x01\x00\x02\x00\x00\x00\x03 '
@@ -2049,6 +2042,7 @@ Threading
20492042* ** That is why using multiple threads won't result in a faster execution, unless at least one of the threads contains an I/O operation.**
20502043``` python
20512044from threading import Thread, RLock, Semaphore, Event, Barrier
2045+ from concurrent.futures import ThreadPoolExecutor
20522046```
20532047
20542048### Thread
@@ -2084,10 +2078,6 @@ with lock:
20842078
20852079### Thread Pool Executor
20862080** Object that manages thread execution.**
2087- ``` python
2088- from concurrent.futures import ThreadPoolExecutor
2089- ```
2090-
20912081``` python
20922082< Exec> = ThreadPoolExecutor(max_workers = None ) # Or: `with ThreadPoolExecutor() as <name>: …`
20932083< Exec> .shutdown(wait = True ) # Blocks until all threads finish executing.
0 commit comments