Browse Source

Readme

pull/1/head
Jure Šorn 7 years ago
parent
commit
eb88255d9b
1 changed files with 13 additions and 13 deletions
  1. 26
      README.md

26
README.md

@ -59,6 +59,11 @@ Set
frozenset() # Is hashable and can be used as a key in dictionary. frozenset() # Is hashable and can be used as a key in dictionary.
``` ```
### Frozenset
#### Is hashable and can be used as a key in dictionary:
```python
<set> = frozenset()
```
Range Range
----- -----
@ -390,7 +395,7 @@ os.popen(<command>).read()
file_name = input('Enter a file name: ') file_name = input('Enter a file name: ')
``` ```
### Print lines until EOF #### Prints lines until EOF:
```python ```python
while True: while True:
try: try:
@ -471,9 +476,7 @@ lock.release()
Itertools Itertools
--------- ---------
#### Every function returns a generator and can accept any collection. If you want to #### Every function returns a generator and can accept any collection. If you want to print an output of generator, as in examples, you need to pass it to `list()` function.
print an output of generator, as in examples, you need to pass it to _list()_
function.
```python ```python
from itertools import * from itertools import *
@ -541,7 +544,7 @@ islice([1, 2, 3], 1, None)
``` ```
### Ifilter, imap and izip ### Ifilter, imap and izip
* #### Filter, map and zip functions that return generators instead of iterators. #### Filter, map and zip functions that return generators instead of iterators.
Introspection and Metaprograming Introspection and Metaprograming
@ -586,8 +589,7 @@ False
``` ```
### Type ### Type
EEEE Type is the root class. If only passed the object it returns it's type. #### Type is the root class. If only passed the object it returns it's type. Otherwise it creates a new class (and not the instance!):
Otherwise it creates a new class (and not the instance!).
```python ```python
type(class_name, parents<tuple>, attributes<dict>) type(class_name, parents<tuple>, attributes<dict>)
``` ```
@ -613,7 +615,7 @@ class MyMetaClass(type):
``` ```
### Metaclass Attr ### Metaclass Attr
#### When class is created it checks if it has metaclass defined. If not, it recursively checks if any of his parents has it defined, and eventually comes to type. #### When class is created it checks if it has metaclass defined. If not, it recursively checks if any of his parents has it defined, and eventually comes to type:
```python ```python
class BlaBla: class BlaBla:
__metaclass__ = Bla __metaclass__ = Bla
@ -700,13 +702,11 @@ def send_page(sport):
```python ```python
@post('/p/<sport>') @post('/p/<sport>')
def p_handler(sport): def p_handler(sport):
team_1 = request.forms.get('team_1') team = request.forms.get('team')
team_2 = request.forms.get('team_2') team = urllib.parse.unquote(team).lower()
team_1 = urllib.parse.unquote(team_1).lower()
team_2 = urllib.parse.unquote(team_2).lower()
db = sqlite3.connect(conf.DB_PATH) db = sqlite3.connect(conf.DB_PATH)
p_h, p_a = get_p(db, sport, team_1, team_2) p_h, p_a = get_p(db, sport, team)
db.close() db.close()
response.headers['Content-Type'] = 'application/json' response.headers['Content-Type'] = 'application/json'

|||||||
100:0
Loading…
Cancel
Save