Created
July 7, 2015 20:57
-
-
Save asalt/73375c0533be2fb49932 to your computer and use it in GitHub Desktop.
Sample of how to use positional, optional, keyword, and optional keyword arguments for a function
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 func_ex(p_arg, *args, preset_guy = 'billy', **kwargs): | |
''' | |
Example function on how to pass required positional, optional positional, | |
keyword arguments, and optional keyword arguments | |
''' | |
print('positional argument value is : {}'.format(p_arg)) | |
for arg in args: | |
print('Another arg is here boys : \n{}'.format(arg)) | |
print('Preset guy is set to {}'.format(preset_guy)) | |
if kwargs is not None: | |
for key, value in kwargs.items(): | |
print('Here comes another kwarg boys : \n{} == {}'.format(key,value)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment