Skip to content

Instantly share code, notes, and snippets.

@Larusso
Last active December 19, 2015 03:48
Show Gist options
  • Save Larusso/5892640 to your computer and use it in GitHub Desktop.
Save Larusso/5892640 to your computer and use it in GitHub Desktop.
Pack and unpack function arguments in python
#!/usr/bin/python
#coding: utf-8
def _test_a(*args, **kvargs):
if args:
_test_function(*args)
else if kvargs:
_test_function(**kvargs)
def _test_function(stringValue, intValue, floatValue):
print 'value1: %s, value2: %d, value3: %f' % (stringValue, intValue, floatValue)
_test_a('Mike',2,3.2)
list_params = ['Udo',7,99.5]
_test_a(*list_params)
dict_params = {'stringValue': 'Nami', 'intValue': 23, 'floatValue': 34.67}
_test_a(**dict_params)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment