On Wed, Oct 09, 2013 at 04:15:36PM +0200, Larry Hastings wrote: > >- parameters in optional groups should just have an implied "=None" > >that can be overriden if desired. > > > > No no no! You can't have a default value, and you definitely couldn't > use None. > > range() decides what its arguments mean based on how many arguments it > receives. If I understand your proposal correctly, you suggest that > > range(None, 5) > > would return the same result as > > range(5) > > But that's simply not how it works.
Hmmm... I'm not entirely sure that I understand, but let me see if I've got it. range is defined something like this, only in C: def range(*args): if len(args) == 1: start, stop, step = 0, args[0], 1 elif len(args) == 2: start, stop, step = args[0], args[1], 1 elif len(args) == 3: start, stop, step = args else: raise TypeError ... So we can't document range as having the signature: range(start=None, stop, range=None) (modulo choice of defaults). Even if some future implementation of positional-only arguments allowed functions to set defaults, you would still have to deal with cases like range that don't. Do I understand you correctly? If so, then I ask that this PEP should not rule out setting defaults in the the future, but make it clear that even if defaults are allowed, there needs to be some way to handle defaultless-but-still-optional arguments, for cases like range. -- Steven _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com