Created
May 23, 2018 19:31
-
-
Save MXWest/11155292a1033e1bde3b9e0bb3d2dd18 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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