Skip to content

Instantly share code, notes, and snippets.

@asalt
Created July 7, 2015 20:57
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 asalt/73375c0533be2fb49932 to your computer and use it in GitHub Desktop.
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
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