[Python-Dev] PEP 457: Syntax For Positional-Only Parameters
Larry Hastings
larry at hastings.org
Wed Oct 9 16:53:15 CEST 2013
On 10/09/2013 04:26 PM, Georg Brandl wrote:
>> I realize you are -1 on the proposal in general, but I'd be very interested if
>> you could propose an alternate approach where I didn't need "a new spelling for
>> None" as you put it.
> I think I would make Steven's proposed syntax mandatory: let the implementor
> of the function decide which value stands for "not given" -- just like we do
> in the C version, BTW.
But that's not how addch works. addch counts how many arguments it
received; if it is called with one or two, it does one thing, and if
it's called with three or four it does something else. You can't
duplicate these semantics with
Similarly, you can't accurately express the semantics of range's
arguments using default values. PyPy's approach is approximately like this:
def range(x, y=None, step=None):
step = 1 if step is None else step
if y is not None:
start, stop = x, y
else:
start, stop = 0, x
But now introspection information on range() is inaccurate and
unhelpful. (Not to mention, they allow specifying step without
specifying y, by using keyword arguments.)
My goal in writing the PEP was to codify existing practice, which meant
reflecting these (annoying!) corner cases accurately.
//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131009/afcadf9c/attachment.html>
More information about the Python-Dev
mailing list