Merge pull request #4757 from smith558/patch-9

[python/en] Clarify args and kwargs
This commit is contained in:
Marcel Ribeiro-Dantas 2023-09-21 19:33:34 -03:00 committed by GitHub
commit c6bca8aa52
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)