Verbose and flexible args and kwargs syntax

Eelco hoogendoorn.eelco at gmail.com
Tue Dec 13 03:31:21 EST 2011


On Dec 13, 1:34 am, Ian Kelly <ian.g.ke... at gmail.com> wrote:
> On Mon, Dec 12, 2011 at 11:51 AM, Eelco <hoogendoorn.ee... at gmail.com> wrote:
> > Either way, its not hard to add some detail to the semantics to allow
> > all this. Even this function definition:
>
> > def func(Foo(args), Foo(kwargs))
>
> > ...could even be defined unambigiously by overloading first on base
> > type, and if that does not uniquely determine the args and kwargs,
> > fall back on positionality, so that:
>
> > def func(Foo(args), dict(kwargs))
> > def func(list(args), Foo(kwargs))
>
> > would be uniquely defined as well.
>
> That solves some of the problems, but if I just have:
>
>         def func(SequenceOrMappingType(args)):
>
> That's going to unpack positionally.  If I want it to unpack keywords
> instead, how would I change the definition to indicate that?

That should raise an ambiguity error. But honestly, how often have you
worked with SequenceOrMappingType's? I think this is a rather
palatable constraint.



More information about the Python-list mailing list