Skip to content

Instantly share code, notes, and snippets.

@MXWest
Created May 23, 2018 19: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 MXWest/11155292a1033e1bde3b9e0bb3d2dd18 to your computer and use it in GitHub Desktop.
Save MXWest/11155292a1033e1bde3b9e0bb3d2dd18 to your computer and use it in GitHub Desktop.
def method_with_positional_args(a, b, c, d):
def print_me(arg):
print("Got {}".format(arg))
print_me(a)
print_me(b)
print_me(c)
print_me(d)
def method_with_kwargs(first=None, second=None, third=None, fourth=None):
def print_me(arg):
print("Got {}".format(arg))
print_me("first: {}".format(first))
print_me("second: {}".format(second))
print_me("third: {}".format(third))
print_me("fourth: {}".format(fourth))
arg_set = ("a", "b", "c", "d")
arg_list = ["d", "c", "b", "a"]
kwarg_dict = {
"first": "a",
"fourth": "d",
"second": "b",
"third": "c",
}
print("Call with args:")
method_with_positional_args("a", "b", "c", "d")
print("Call with arg_set:")
method_with_positional_args(*arg_set)
print("Call with arg_list:")
method_with_positional_args(*arg_list)
print("Call with kwarg_dict")
method_with_kwargs(**kwarg_dict)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment