Function arguments

Thomas Heller thomas.heller at ion-tof.com
Thu Oct 18 07:03:48 EDT 2001


"Martin Franklin" <martin.franklin at westgeo.com> wrote:
> Thomas Heller wrote:
>
> > Call me weird, but sometimes I need functions taking a number of
> > positional arguments, some named arguments with default values, and
> > other named arguments as well.
> >
> > Something like this (which does _not_ work):
> >
> > def function(*args, defarg1=None, defarg2=0, **kw):
> >     ...
>
>
> -- snip --
>
>
> What about this:
>
> def function(defarg1=None, defarg2=0, *args, **kw):
Doesn't work. A call like
  function(1, 2, 3)
should result in
  args = (1, 2, 3), defarg1 = None, defarg2 = 0

Thomas





More information about the Python-list mailing list