Clarify args and kwargs

This commit is contained in:
Stanislav (Stanley) Modrak 2023-09-21 17:26:42 +01:00 committed by GitHub
parent 143d61db13
commit 0a0b3555d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -603,7 +603,7 @@ all_the_args(1, 2, a=3, b=4) prints:
""" """
# When calling functions, you can do the opposite of args/kwargs! # When calling functions, you can do the opposite of args/kwargs!
# Use * to expand tuples and use ** to expand kwargs. # Use * to expand args (tuples) and use ** to expand kwargs (dictionaries).
args = (1, 2, 3, 4) args = (1, 2, 3, 4)
kwargs = {"a": 3, "b": 4} kwargs = {"a": 3, "b": 4}
all_the_args(*args) # equivalent: all_the_args(1, 2, 3, 4) all_the_args(*args) # equivalent: all_the_args(1, 2, 3, 4)