[Python-ideas] Positional only arguments

Aaron Brady castironpi at comcast.net
Tue May 22 01:03:25 CEST 2007


> -----Original Message-----
> From: python-ideas-bounces at python.org [mailto:python-ideas-
> bounces at python.org] On Behalf Of Ron Adam
> 
> If '^' is used outside of function defs like the '*', it can retain it's
> meaning.
> 
> a, b, *c = 1, 2, 3, 4, 5    # pack remainder
> 
> z = (x, y, z)
> a, b, c, d = (a, ^z)        # unpack z

Don't forget.  Any the things you want can be composed in hand.

> >>>     def f(*, a, b=None, *args, **, c=42, **kwargs)

def f( *args, **kwargs ):
	if len( args ) < 2: raise error
	if 'b' in kwargs: raise error
	if 'c' not in kwargs: raise error
	a, b, args = args[:2], args[2:]
	c = kwargs['c']

It's an approximation; use case to the contrary?




More information about the Python-ideas mailing list