On 4/20/06, Greg Ewing <[EMAIL PROTECTED]> wrote:
> Some wilder ideas for keyword-only arguments:

>    def spam(a, b, c, {d, e, f=x}):
>      # d, e are mandatory keyword-only
>      # f is optional keyword-only

I see several sources of complexity.

Long sequences where order matters are bad, but probably can't be
eliminated.  We have this today.

A rest-of-the-arguments collector is a useful special case.  We have
this today with *.

Arguments which can be either positional or keywords are tricky, but
also useful.  We have this today.

A distinction between expected and unexpected keywords is awkward, but
sometimes useful.  We have this today with **.

Today, we do not have any way to say that a parameter is keyword only
without also marking it unexpected.  This motivates the addition of

    def(pos1, pos2, *args, key1=XXX):

I also see the value of keyword-only arguments without unlimited
positional arguments.  Whether it deserves syntax and what that syntax
should be (such as * or *None)  may need a pronouncement eventually,
but it doesn't have to be complex.

The *new* complexity seems to come almost entirely from trying to
support keyword-only arguments without a default.  I don't think

    (mandatory) + (keyword only) + (no default) + (no sentinel)

is important enough to justify that complexity.

(That said, I would like a better way to tell whether the keyword was
passed explicitly; creating a sentinel outside the function always
seems awkward.)

-jJ
_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to