Problem:
There are two special situations in the Function Definition of Python: The *, * form.
For example, Def execute_command (self, * ARGs, ** options.
Explanation:
* This parameter is used to pass any parameter without a name. These parameters are accessed in a tuple format.
** It is used to process and pass any parameter with a name. These parameters are accessed by dict.
Application:
#########################
# "*" Application
#########################
>>> Def fun1 (* keys ):
... Print "keys type = % s" % type (keys)
... Print "keys = % s" % STR (keys)
... For I in range (0, Len (KEYS )):
... Print "keys [" + STR (I) + "] = % s" % STR (Keys [I])
...
>>> Fun1 (2, 3, 4, 5)
Output the following results:
Keys type = <type 'tuple'>
Keys = (2, 3, 4, 5)
Keys [0] = 2
Keys [1] = 3
Keys [2] = 4
Keys [3] = 5
#########################
# "**" Applications
#########################
>>> Def fun2 (** keys ):
... Print "keys type = % s" % type (keys)
... Print "keys = % s" % str (keys)
... Print "name = % s" % str (keys ['name'])
...
>>>
>>> Fun2 (name = "vp", age = 19)
Output the following results:
Keys type = <type 'dict '>
Keys = {'age': 19, 'name': 'vp '}
Name = vp
Source: http://harmony.relax.blogbus.com/logs/12303417.html