Browse Source

Removed spaces before new lines

pull/28/head
Jure Šorn 6 years ago
parent
commit
5ab93d30ef
1 changed files with 26 additions and 26 deletions
  1. 52
      README.md

52
README.md

@ -46,11 +46,11 @@ list_of_chars = list(<str>)
``` ```
```python ```python
index = <list>.index(<el>) # Returns first index of item.
index = <list>.index(<el>) # Returns first index of item.
<list>.insert(index, <el>) # Inserts item at index and moves the rest to the right. <list>.insert(index, <el>) # Inserts item at index and moves the rest to the right.
<el> = <list>.pop([index]) # Removes and returns item at index or from the end. <el> = <list>.pop([index]) # Removes and returns item at index or from the end.
<list>.remove(<el>) # Removes first occurrence of item or raises ValueError. <list>.remove(<el>) # Removes first occurrence of item or raises ValueError.
<list>.clear() # Removes all items.
<list>.clear() # Removes all items.
``` ```
@ -289,9 +289,9 @@ import re
``` ```
* **Parameter `'flags=re.IGNORECASE'` can be used with all functions.** * **Parameter `'flags=re.IGNORECASE'` can be used with all functions.**
* **Parameter `'flags=re.DOTALL'` makes dot also accept newline.**
* **Use `r'\1'` or `'\\1'` for backreference.**
* **Use `'?'` to make operator non-greedy.**
* **Parameter `'flags=re.DOTALL'` makes dot also accept newline.**
* **Use `r'\1'` or `'\\1'` for backreference.**
* **Use `'?'` to make operator non-greedy.**
### Match Object ### Match Object
```python ```python
@ -424,7 +424,7 @@ from itertools import product, combinations, combinations_with_replacement, perm
```python ```python
>>> product([0, 1], repeat=3) >>> product([0, 1], repeat=3)
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1),
[(0, 0, 0), (0, 0, 1), (0, 1, 0), (0, 1, 1),
(1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)] (1, 0, 0), (1, 0, 1), (1, 1, 0), (1, 1, 1)]
``` ```
@ -441,15 +441,15 @@ from itertools import product, combinations, combinations_with_replacement, perm
```python ```python
>>> combinations_with_replacement('abc', 2) >>> combinations_with_replacement('abc', 2)
[('a', 'a'), ('a', 'b'), ('a', 'c'),
('b', 'b'), ('b', 'c'),
[('a', 'a'), ('a', 'b'), ('a', 'c'),
('b', 'b'), ('b', 'c'),
('c', 'c')] ('c', 'c')]
``` ```
```python ```python
>>> permutations('abc', 2) >>> permutations('abc', 2)
[('a', 'b'), ('a', 'c'),
('b', 'a'), ('b', 'c'),
[('a', 'b'), ('a', 'c'),
('b', 'a'), ('b', 'c'),
('c', 'a'), ('c', 'b')] ('c', 'a'), ('c', 'b')]
``` ```
@ -505,7 +505,7 @@ from dateutil.tz import UTC, tzlocal, gettz
* **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.ffffff[±<offset>]'`, or both separated by `'T'`.** * **ISO strings come in following forms: `'YYYY-MM-DD'`, `'HH:MM:SS.ffffff[±<offset>]'`, or both separated by `'T'`.**
* **On Unix systems Epoch is `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...** * **On Unix systems Epoch is `'1970-01-01 00:00 UTC'`, `'1970-01-01 01:00 CET'`, ...**
### Decode
### Decode
```python ```python
<str> = <D/T/DT>.isoformat() # ISO string representation. <str> = <D/T/DT>.isoformat() # ISO string representation.
<str> = <D/T/DT>.strftime('<format>') # Custom string representation. <str> = <D/T/DT>.strftime('<format>') # Custom string representation.
@ -549,7 +549,7 @@ Splat Operator
```python ```python
args = (1, 2) args = (1, 2)
kwargs = {'x': 3, 'y': 4, 'z': 5} kwargs = {'x': 3, 'y': 4, 'z': 5}
func(*args, **kwargs)
func(*args, **kwargs)
``` ```
#### Is the same as: #### Is the same as:
@ -677,7 +677,7 @@ creature = Creature()
Closure Closure
------- -------
**We have a closure in Python when:** **We have a closure in Python when:**
* **A nested function references a value of its enclosing function and then**
* **A nested function references a value of its enclosing function and then**
* **the enclosing function returns the nested function.** * **the enclosing function returns the nested function.**
```python ```python
@ -839,7 +839,7 @@ class MyComparable:
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, type(self)): if isinstance(other, type(self)):
return self.a == other.a return self.a == other.a
return False
return False
``` ```
### Hashable ### Hashable
@ -857,7 +857,7 @@ class MyHashable:
def __eq__(self, other): def __eq__(self, other):
if isinstance(other, type(self)): if isinstance(other, type(self)):
return self.a == other.a return self.a == other.a
return False
return False
def __hash__(self): def __hash__(self):
return hash(self.a) return hash(self.a)
``` ```
@ -928,7 +928,7 @@ Enum
from enum import Enum, auto from enum import Enum, auto
class <enum_name>(Enum): class <enum_name>(Enum):
<member_name_1> = <value_1>
<member_name_1> = <value_1>
<member_name_2> = <value_2_a>, <value_2_b> <member_name_2> = <value_2_a>, <value_2_b>
<member_name_3> = auto() <member_name_3> = auto()
@ -1278,7 +1278,7 @@ Bytes
### Decode ### Decode
```python ```python
<str> = <bytes>.decode(encoding='utf-8')
<str> = <bytes>.decode(encoding='utf-8')
<int> = int.from_bytes(<bytes>, byteorder='big|little', signed=False) <int> = int.from_bytes(<bytes>, byteorder='big|little', signed=False)
<hex> = <bytes>.hex() <hex> = <bytes>.hex()
``` ```
@ -1352,7 +1352,7 @@ Memory View
**Used for accessing the internal data of an object that supports the buffer protocol.** **Used for accessing the internal data of an object that supports the buffer protocol.**
```python ```python
<memoryview> = memoryview(<bytes> / <bytearray> / <array>)
<memoryview> = memoryview(<bytes> / <bytearray> / <array>)
<memoryview>.release() <memoryview>.release()
``` ```
@ -1494,7 +1494,7 @@ last_el = op.methodcaller('pop')(<list>)
``` ```
Eval
Eval
---- ----
### Basic ### Basic
```python ```python
@ -1555,14 +1555,14 @@ def eval_node(node):
Coroutine Coroutine
--------- ---------
* **Similar to generator, but generator pulls data through the pipe with iteration, while coroutine pushes data into the pipeline with send().**
* **Coroutines provide more powerful data routing possibilities than iterators.**
* **If you built a collection of simple data processing components, you can glue them together into complex arrangements of pipes, branches, merging, etc.**
* **Similar to generator, but generator pulls data through the pipe with iteration, while coroutine pushes data into the pipeline with send().**
* **Coroutines provide more powerful data routing possibilities than iterators.**
* **If you built a collection of simple data processing components, you can glue them together into complex arrangements of pipes, branches, merging, etc.**
### Helper Decorator ### Helper Decorator
* **All coroutines must be "primed" by first calling next().**
* **Remembering to call next() is easy to forget.**
* **Solved by wrapping coroutines with a decorator:**
* **All coroutines must be "primed" by first calling next().**
* **Remembering to call next() is easy to forget.**
* **Solved by wrapping coroutines with a decorator:**
```python ```python
def coroutine(func): def coroutine(func):
@ -1691,7 +1691,7 @@ rotation=<int>|<datetime.timedelta>|<datetime.time>|<str>
retention=<int>|<datetime.timedelta>|<str> retention=<int>|<datetime.timedelta>|<str>
``` ```
* **`'<int>'` - Max number of files.** * **`'<int>'` - Max number of files.**
* **`'<timedelta>'` - Max age of a file.**
* **`'<timedelta>'` - Max age of a file.**
* **`'<str>'` - Max age as a string: `'1 week, 3 days'`, `'2 months'`, ...** * **`'<str>'` - Max age as a string: `'1 week, 3 days'`, `'2 months'`, ...**
### Compression ### Compression

Loading…
Cancel
Save