|
@ -88,7 +88,7 @@ Iterator |
|
|
for line in iter(input, ''): |
|
|
for line in iter(input, ''): |
|
|
pass |
|
|
pass |
|
|
``` |
|
|
``` |
|
|
Use partial from functools if function needs arguments. |
|
|
|
|
|
|
|
|
Use _partial_ from functools if function needs arguments. |
|
|
|
|
|
|
|
|
#### Skips first element |
|
|
#### Skips first element |
|
|
```python |
|
|
```python |
|
@ -248,12 +248,12 @@ functools.reduce(combining_function, list_of_inputs) |
|
|
|
|
|
|
|
|
### Any, All |
|
|
### Any, All |
|
|
```python |
|
|
```python |
|
|
any(el[1] for el in <collection>) # <boolean> |
|
|
|
|
|
|
|
|
any(el[1] for el in <collection>) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
### If - Else |
|
|
### If - Else |
|
|
```python |
|
|
```python |
|
|
expression_if_true if condition else expression_if_false |
|
|
|
|
|
|
|
|
<expression_if_true> if <condition> else <expression_if_false> |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
Closure |
|
|
Closure |
|
@ -314,7 +314,7 @@ class <name>: |
|
|
```python |
|
|
```python |
|
|
import enum |
|
|
import enum |
|
|
class <enum_name>(enum.Enum): |
|
|
class <enum_name>(enum.Enum): |
|
|
<name1> = <value1> # Or "= enum.auto()"" for automatic indexing. |
|
|
|
|
|
|
|
|
<name1> = <value1> # Or "= enum.auto()" for automatic indexing. |
|
|
<name2> = <value2> |
|
|
<name2> = <value2> |
|
|
... |
|
|
... |
|
|
``` |
|
|
``` |
|
|