Browse Source

Random

pull/3/head
Jure Šorn 6 years ago
parent
commit
9f9d61f074
1 changed files with 3 additions and 2 deletions
  1. 5
      README.md

5
README.md

@ -466,8 +466,8 @@ functools.reduce(lambda sum, x: sum+x, range(10)) # 45
``` ```
```python ```python
>>> [a if a else 2 for a in [0, 1, 0, 3]]
[2, 1, 2, 3]
>>> [a if a else 'zero' for a in (0, 1, 0, 3)]
['zero', 1, 'zero', 3]
``` ```
### Namedtuple, Enum, Class ### Namedtuple, Enum, Class
@ -481,6 +481,7 @@ Cutlery = Enum('Cutlery', {'knife': 1, 'fork': 2, 'spoon': 3})
# Warrning: Objects will share the objects that are initialized in the dict! # Warrning: Objects will share the objects that are initialized in the dict!
Creature = type('Creature', (), {'position': Point(0, 0), 'direction': Direction.n}) Creature = type('Creature', (), {'position': Point(0, 0), 'direction': Direction.n})
creature = Creature()
``` ```

Loading…
Cancel
Save