[Python-3000] PEP 3102 comments
Nick Coghlan
ncoghlan at gmail.com
Thu May 25 12:34:52 CEST 2006
Greg Ewing wrote:
> tomer filiba wrote:
>> talin asked for comments, so
>>
>> def f(a, b, *, c, d)
>>
>> seems wrong to me. '*' can't be a token on its own, at least
>> that's the way i see it. opeators shouldn't stand for themselves.
>
> But * is not an operator here. It's just a token
> with a special meaning in this context.
>
> I don't really understand why this is so controversial.
> To me, it's the obvious least-change way of introducing
> the feature concerned. As someone said, it's just
> "*args without the args".
While the naked star syntax is fine by me, permitting tuple-expansion for
*args would also do the trick (as well as permitting positional only arguments).
That is,
def f(a, b, *args, c, d):
# Arbitrary number of extra positional arguments allowed
def f(a, b, *(pos1, pos2), c, d):
# Exactly 2 extra positional arguments required
def f(a, b, *(pos1,), c, d):
# Exactly 1 extra positional argument required
def f(a, b, *(), c, d):
# Exactly 0 extra positional arguments required
# (In other words, no extra positional arguments permitted)
Although even that still wouldn't allow the signature for dict.update to be
expressed correctly. Doing that would require the ability to specify optional
positional only arguments:
def update(*(self, other=None), **kwds):
# self & other can still be used as keyword arguments
# and end up in the kwds dictionary
Just something to consider.
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
---------------------------------------------------------------
http://www.boredomandlaziness.org
More information about the Python-3000
mailing list