Verbose and flexible args and kwargs syntax

Duncan Booth duncan.booth at invalid.invalid
Sun Dec 11 07:39:44 EST 2011


Chris Angelico <rosuav at gmail.com> wrote:
> 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.

If it used keywords then you could keep symmetry quite easily:

    def anyargs(arglist args, argdict kwargs):
        return wrappedfunc(arglist args, argdict kwargs)

and you would have the advantage of two new keywords that people could 
actually search on.

> 
> 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?

Irrelevant, you can't subclass both list and dict:

>>> class C(list, dict): pass

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    class C(list, dict): pass
TypeError: multiple bases have instance lay-out conflict



-- 
Duncan Booth http://kupuguy.blogspot.com



More information about the Python-list mailing list