Skip to content

Commit 51098f9

Browse files
committed
Applied feedback from code review.
1 parent 0317aea commit 51098f9

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

concepts/function-arguments/about.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ print(concat("Hello, ", "Lilly"))
2323

2424
# Passing data to the function using the parameter name.
2525
print(concat(name="Glenn", greeting="Hello, "))
26-
2726
#-> Hello, Glenn
2827
```
2928

@@ -72,7 +71,7 @@ def concat(greeting, name):
7271

7372
# Function call using parameter names as argument keywords.
7473
print(concat(name="Eliza", greeting="Hello, "))
75-
#--> Hello, Eliza
74+
#-> Hello, Eliza
7675

7776
# Function call with positional data as arguments.
7877
print(concat("Hello, ", "Tim"))
@@ -109,11 +108,11 @@ def concat(greeting, name="you", punctuation="!"):
109108
return f"{greeting}, {name}{punctuation}"
110109

111110
print(concat("Hello"))
112-
Hello, you!
111+
#-> Hello, you!
113112

114113
# Overriding the default values
115114
print(concat("Hello", name="Polly", punctuation="."))
116-
Hello, Polly.
115+
#-> Hello, Polly.
117116
```
118117

119118

@@ -128,12 +127,12 @@ def concat(greeting, /, name, *, ending):
128127
return f"{greeting}{name}{ending}"
129128

130129
print(concat("Hello, ", "Mark", ending="!"))
131-
Hello, Mark!
130+
#-> Hello, Mark!
132131

133132
print(concat("Hello, ", name="Rachel", ending="!"))
134-
Hello, Rachel!
133+
#-> Hello, Rachel!
135134

136-
>>> print(concat(greeting="Hello, ", name="JoJo", ending="!"))
135+
print(concat(greeting="Hello, ", name="JoJo", ending="!"))
137136
Traceback (most recent call last):
138137
print(concat(greeting="Hello, ", name="JoJo", ending="!"))
139138
TypeError: concat() got some positional-only arguments passed as keyword arguments: 'greeting'
@@ -209,7 +208,7 @@ print(add(*[1, 2, 3]))
209208
#-> 6
210209
```
211210

212-
Note that when an argument is already inside an `iterable` such as a `tuple` or `list`, it needs to be [_unpacked_][unpacking-and-multiple-assignment] before being passed to a function that takes an arbitrary number of separate arguments.
211+
Note that when an argument is already inside an `iterable` (_such as a `tuple` or `list`_), it needs to be [_unpacked_][unpacking-and-multiple-assignment] before being passed to a function that takes an arbitrary number of separate arguments.
213212
This is accomplished by using `*`, which is the [unpacking operator][unpacking operator].
214213

215214
`*` in this context _unpacks_ the container into its separate elements which are then transformed by `*args` into a `tuple`.

concepts/function-arguments/introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ print(concat(name="Jerry", greeting="Hello, "))
6262

6363
# Function call without arguments resulting in the defaults being used.
6464
print(concat())
65-
#--> Hello, you
65+
#-> Hello, you
6666
```
6767

6868
## Keyword Arguments

0 commit comments

Comments
 (0)