[Python-ideas] keyword arguments everywhere (stdlib) - issue8706

Steven D'Aprano steve at pearwood.info
Sat Mar 3 04:20:09 CET 2012


Raymond Hettinger wrote:
> On Mar 2, 2012, at 2:01 PM, Gregory P. Smith wrote:
> 
>> speaking of range... I think start and stop are plenty obvious, but I'd like to allow step to be specified as a keyword.
> 
> range() has been around 20+ years and this has never been requested.

I have frequently felt that range(start=5, stop=27, step=2) reads better than 
range(5, 27, 2), but not better *enough* to bother requesting a change, 
particular given the conservative nature of the Python devs to such minor 
interface changes (and rightly so).

If it came to a vote, I'd vote 0 on the status quo, +0 to allow all three 
arguments to be optionally given by keyword, and -1 for singling step out as 
the only one that can be a keyword. That's just silly (sorry Gregory!) -- can 
you imagine explaining to a beginner why they can write range(0, 50, 2) or 
range(0, 50, step=2) but not range(0, stop=50, step=2)?



-- 
Steven



More information about the Python-ideas mailing list