Verbose and flexible args and kwargs syntax

Chris Angelico rosuav at gmail.com
Sun Dec 11 06:15:41 EST 2011


On Sun, Dec 11, 2011 at 9:49 PM, Eelco Hoogendoorn
<hoogendoorn.eelco at gmail.com> wrote:
> Problems im still wrestling with: the same syntax could not be used when
> calling a function; that lack of symmetry would make things more confusing,
> not less.

That symmetry is a large factor, IMHO. I can write a wrapper function like this:

def fixedargs(x,y,z):
    return wrappedfunc(x,y,z)

Or like this:

def anyargs(*args,**kwargs):
    return wrappedfunc(*args,**kwargs)

Either way, it's a perfect parallel, and that's very useful for noticing errors.

With a keyworded syntax, that's going to be a lot harder.

Another issue: You suggest being able to use "attrdict" or some other
dict subclass. This means that, rather than being a language
construct, this will involve a name lookup. And what happens if you
have a class that subclasses both list and dict? Will it get the
positional args, the keyword args, or both?

Laudable notion, but I'm not sure that it'll actually work in practice.

ChrisA



More information about the Python-list mailing list