Skip to content

Instantly share code, notes, and snippets.

@Pierre-Sassoulas
Last active November 7, 2021 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pierre-Sassoulas/6c32a7dbf940d6bcb8a771a68533b4f1 to your computer and use it in GitHub Desktop.
Save Pierre-Sassoulas/6c32a7dbf940d6bcb8a771a68533b4f1 to your computer and use it in GitHub Desktop.
Python args/kwargs example
def example(*args, **kwargs):
print("Args:", args, "Kwargs:", kwargs)
args = [1, 2]
kwargs = {"pos_x": 1, "pos_y": 2}
print("Standard call")
example(1, 2)
print("Keyword call")
example(pos_x=1, pos_y=2)
print("Args call")
example(*args)
print("Kwargs call")
example(**kwargs)
print("Strange call")
example(*kwargs)
print("Mixed call")
example("a", b=42, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment