[Pythonmac-SIG] Newby Q's: */**
Jack Jansen
Jack.Jansen@cwi.nl
Mon, 20 Jul 1998 10:53:05 +0200
> For the prefix asterix (*/**) in the following definition (from guipy) I
> cannot find a reference.
>
> def __init__(self, *args, **kw):
> self.menu = []
> apply(Container.__init__, (self,) + args, kw)
>
> Can you explain ?
It's explained in the reference manual (and also slightly in the tutorial),
which you can find at www.python.org. Here's the quick explanation:
- *args gets all "unused" arguments
- **kw gets all "unused" keyword arguments.
Or, as an example, a function
def foo(arg1, *args, **kwargs):
pass
called as
foo(1, 2, 3, spam=4, eggs=5)
will get the values
arg1 = 1
args = (2, 3)
kwargs = { "spam":4, "eggs":5 }
--
Jack Jansen | ++++ stop the execution of Mumia Abu-Jamal ++++
Jack.Jansen@cwi.nl | ++++ if you agree copy these lines to your sig ++++
http://www.cwi.nl/~jack | see http://www.xs4all.nl/~tank/spg-l/sigaction.htm