__init__ question

Emile van Sebille emile at fenx.com
Mon Dec 25 14:09:06 EST 2000


*args (and **kwargs) allow for additional parameters to be
passed to a function.
*args in the def becomes a tuple, **kwargs a dictionary.

>>> def init(a, b, c, *args, **kwargs):
 print a,b,c
 print args
 print kwargs


>>> init(1,2,3,4,5,6,d=7,e=8,f=9)
1 2 3
(4, 5, 6)
{'f': 9, 'd': 7, 'e': 8}
>>>

--

Emile van Sebille
emile at fenx.com
-------------------


"Daniel Klein" <DanielK at aracnet.com> wrote in message
news:EvM16.270$LU6.118037 at typhoon.aracnet.com...
> I'm trying to decipher some Python code and came across
the line:
>
>     def __init__(self, *args):
>
> What is the meaning of the '*args' expression?
>
> Thanks,
> Dan:
>
>





More information about the Python-list mailing list