Python, default keyword arguments after variable length positional arguments
Question: I thought I could use named parameters after variable-length positional
parameters in a function call, but I get a syntax error when importing a
python class I'm writing with the following "get" method, for example:

    
    
    class Foo(object):
        def __init__(self):
            print "You have created a Foo."
    
        def get(self,*args,raw=False,vars=None):
            print len(args)
            print raw
            print vars
    

The error looks like:

    
    
    def get(self,*args,raw=False,vars=None):
                         ^
    SyntaxError: invalid syntax
    

I'd like to be able to call the method several ways:

    
    
    f = Foo()
    f.get(arg1,arg2)
    f.get(arg1,raw=True)
    f.get(arg1,arg2,raw=True,vars=something)
    

...etc.

I've RTFM as much as I can, but it doesn't quite click why this won't work.
Thanks in advance for your help.

-j


Answer: It does work, but only in Python 3. See PEP
[3102](http://www.python.org/dev/peps/pep-3102/). From glancing over the
"what's new" documents, it seems that there is no 2.x backport, so you're out
of luck. You'll have to accept any keyword arguments (`**kwargs`) and manually
parse it (you can use `d.get(k, default)` to either get `d[k]` or `default` if
that's not there).

