Browse Source

Updates

pull/3/head
Jure Šorn 6 years ago
parent
commit
8784ad494e
1 changed files with 15 additions and 0 deletions
  1. 15
      README.md

15
README.md

@ -78,9 +78,14 @@ Set
<set> = set()
<set>.add(<el>)
<set>.update(<set>)
<set>.clear()
```
```python
<set> = <set>.union(<set>)
<set> = <set>.intersection(<set>)
<set> = <set>.difference(<set>)
<set> = <set>.symmetric_difference(<set>)
<bool> = <set>.issubset(<set>)
<bool> = <set>.issuperset(<set>)
```
@ -499,6 +504,13 @@ class <name>:
return cls.__name__
```
#### Constructor overloading:
```python
class C:
def __init__(self, a=None):
self.a = a
```
### Enum
```python
from enum import Enum, auto
@ -540,6 +552,9 @@ Cutlery = Enum('Cutlery', {'knife': 1, 'fork': 2, 'spoon': 3})
# Functions can not be values, so they must be enclosed in tuple:
LogicOp = Enum('LogicOp', {'AND': (lambda l, r: l and r, ),
'OR' : (lambda l, r: l or r, )}
# But 'list(<enum>)' will only work if there is another value in tuple:
LogicOp = Enum('LogicOp', {'AND': (auto(), lambda l, r: l and r),
'OR' : (auto(), lambda l, r: l or r)}
```
### Copy

Loading…
Cancel
Save