On Jan 30, 1:26 pm, sl33k_ <ahsanbag...@gmail.com> wrote: > Hi, > > I am struggling to grasp this concept about def foo(*args). Also, what > is def bar(*args, *kwargs)?
FYI: the python intepretor is your friend! py> def foo(*args): print args py> foo(1) (1,) py> foo(1,2,3) (1, 2, 3) py> foo(1,[1,23], {'hat':'cat'}) (1, [1, 23], {'hat': 'cat'}) py> def bar(*args, **kw): print 'Args:', args print 'Kwds:', kw py> bar(1,2,3, hat='cat', spam='eggs') Args: (1, 2, 3) Kwds: {'hat': 'cat', 'spam': 'eggs'} > Isnt it like self must be the first parameter to the method/function? > If not what are the exceptions? Only *must* with methods! > Also, can the terms method and function be used interchangeably? Can the terms cars and truck be used interchangeably? -- http://mail.python.org/mailman/listinfo/python-list