Skip to content

Commit 1e920ac

Browse files
committed
Splat
1 parent a549bb2 commit 1e920ac

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,9 @@ def f(<default_args>) # def f(x=0, y=0)
450450
def f(<nondefault_args>, <default_args>) # def f(x, y=0)
451451
```
452452

453-
### Splat operator
454-
**`'*'` is the splat operator, that takes a collection as input, and expands it into actual positional arguments in the function call.**
455-
453+
Splat Operator
454+
--------------
455+
### Inside Function Call
456456
```python
457457
args = (1, 2)
458458
kwargs = {'x': 3, 'y': 4, 'z': 5}
@@ -464,7 +464,8 @@ func(*args, **kwargs)
464464
func(1, 2, x=3, y=4, z=5)
465465
```
466466

467-
#### Splat example:
467+
### Inside Function Definition
468+
**It combines zero or more positional arguments into tuple.**
468469
```python
469470
def add(*a):
470471
return sum(a)
@@ -475,7 +476,7 @@ def add(*a):
475476
6
476477
```
477478

478-
### Legal Argument Definitions and Calls
479+
#### Legal argument combinations and calls:
479480
```python
480481
def f(*args) # f(1, 2, 3)
481482
def f(x, *args) # f(1, 2, 3)

0 commit comments

Comments
 (0)