[Python-Dev] PEP 457: Syntax For Positional-Only Parameters (original) (raw)

Steven D'Aprano steve at pearwood.info
Thu Oct 10 00:28:25 CEST 2013


On Wed, Oct 09, 2013 at 09:46:00PM +0100, 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 ...

If there is even the tiniest, faintest chance that positional arguments will be available to functions written in Python some day, -1 to this suggestion. There is no way I want to write code like the above instead of:

def range([start,] stop, [step,] /): if start is Undefined: start = 0 if step is Undefined: step = 1

But what I really want to write is this:

def range(start=0, stop, step=1, /): ...

although maybe we don't want to encourage odd calling signatures by making them too easy to write.

-- Steven



More information about the Python-Dev mailing list