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
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4