Last active
December 19, 2015 03:48
-
-
Save Larusso/5892640 to your computer and use it in GitHub Desktop.
Pack and unpack function arguments in python
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
#!/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