I am scratching my head on what is going in the following code.
class foo(object):
def __init__(self,*args):
print type(args)
print args
j_dict = {'rmaNumber':1111, 'caseNo':2222}
print type(j_dict)
p = foo(j_dict)
it yields :
<type 'dict'>
<type 'tuple'>
({'rmaNumber': 1111, 'caseNo': 2222},)
It seems to me that this code converts a dict to a tuple!! Can anyone explain this
Actually it’s because
argsis atupleto hold a variable length argument list.args[0]is still yourdict– no conversion has taken place.See this tutorial for further information about
argsandkwargs(the keyword version of args).