[Python-Dev] PEP 457: Syntax For Positional-Only Parameters
Larry Hastings
larry at hastings.org
Wed Oct 9 22:51:30 CEST 2013
On 10/09/2013 10:46 PM, Mark Shannon wrote:
> There is no need to create an "undefined" value.
> Rather than define a parameter by assigning a fake value, just don't
> define it. We already do this for non-parameter locals and it could be
> extended to parameters.
>
> 'range' would be defined thus:
>
> def range([start,] stop, [step], /):
> try:
> start
> except UnboundLocalError:
> start = 0
> try:
> step
> except UnboundLocalError:
> step = 1
> ...
That's a clever, and intuitive, idea. Though the try/excepts look
awfully clumsy.
Perhaps we could add (egad, no, I can't believe I'm saying this) a new
built-in function that tells you whether or not a local variable has
been assigned to yet?
def range([start,] stop, [step], /):
if not bound(start):
start = 0
if not bound(step):
step = 1
...
Anyway, this section is in the "Notes For Future Implementors" section,
so as long as we never actually implement the syntax we don't need to
solve the problem.
//arry/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20131009/73b62b05/attachment.html>
More information about the Python-Dev
mailing list