Browse Source

Parameters

pull/3/head
Jure Šorn 6 years ago
parent
commit
045a3e2a65
1 changed files with 9 additions and 0 deletions
  1. 9
      README.md

9
README.md

@ -27,6 +27,7 @@ List
sum_of_elements = sum(<list>)
sorted_by_second = sorted(<list>, key=lambda el: el[1])
flattened_list = [item for sublist in <list> for item in sublist]
elementwise_sum = [sum(pair) for pair in zip(list_a, list_b)]
list_of_chars = list(<str>)
```
@ -279,6 +280,13 @@ func(*args, **kwargs)
func(1, 2, x=3, y=4, z=5)
```
**Splat operator can also be used in function declaration:**
```python
>>> def add(*a):
... return sum(a)
>>> add(1, 2, 3)
6
```
Inline
------
@ -379,6 +387,7 @@ class <name>:
self.a = a
def __repr__(self):
return str({'a': self.a})
# Use f'{s.__dict__}' for all members.
def __str__(self):
return str(self.a)
```

Loading…
Cancel
Save