Browse Source

Dict filter fixed

pull/3/head
Jure Šorn 6 years ago
parent
commit
69eedbb124
1 changed files with 12 additions and 3 deletions
  1. 15
      README.md

15
README.md

@ -39,7 +39,7 @@ Dictionary
```python ```python
collections.defaultdict(<type>) # Creates a dictionary with default values. collections.defaultdict(<type>) # Creates a dictionary with default values.
dict(zip(keys, values)) # Initiates a dict from two lists. dict(zip(keys, values)) # Initiates a dict from two lists.
{k: v for k, v in <dict>.iteritems() if k in <list>} # Filters a dict by keys.
{k: v for k, v in <dict>.items() if k in <list>} # Filters a dict by keys.
``` ```
### Counter ### Counter
@ -138,7 +138,7 @@ type(<el>) # <class 'int'> / <class 'str'> / ...
``` ```
```python ```python
import numbers import numbers
isinstance(<el>, numbers.Number)
isinstance(<el>, numbers.Number) # numbers.Integral, numbers.Real
``` ```
@ -404,10 +404,19 @@ def read_file(filename):
### Write to File ### Write to File
```python ```python
def write_to_file(filename, text): def write_to_file(filename, text):
with open(filename, 'w', enconding='utf-8') as file:
with open(filename, 'w', encoding='utf-8') as file:
file.write(text) file.write(text)
``` ```
### Path
```python
imort os
os.path.exists(<path>)
os.path.isfile(<path>)
os.path.isdir(<path>)
os.listdir(<path>)
```
### Execute Command ### Execute Command
```python ```python
import os import os

Loading…
Cancel
Save