On Wed, Oct 27, 2021 at 1:15 PM Brendan Barnwell <brenb...@brenbarn.net> wrote: > > On 2021-10-26 17:41, Christopher Barker wrote: > > Python used to be such a simple language, not so much anymore :-( > > I quite agree, and I feel like this is my biggest reason why I don't > want this "feature" (or any of another gazillion features that have been > suggested and/or accepted here, including the walrus). The benefit of > this PEP simply does not justify the added complexity of the language as > a whole. Using None (or some sentinel) and including code to check for > it works fine. It's not worth it to add a whole new layer of behavior > to something as basic as argument-passing just to avoid having to type > `if arg is None`. >
>>> help(bisect.bisect) bisect_right(a, x, lo=0, hi=None, *, key=None) ... Optional args lo (default 0) and hi (default len(a)) bound the slice of a to be searched. In the docstring, both lo and hi are given useful, meaningful defaults. In the machine-readable signature, which is also what would be used for tab completion or other tools, lo gets a very useful default, but hi gets a default of None. For the key argument, None makes a very meaningful default; it means that no transformation is done. But in the case of hi, the default really and truly is len(a), but because of a technical limitation, that can't be written that way. Suppose this function were written as: bisect_right(a, x, lo=None, hi=None, *, key=None) Do we really need the ability to specify actual function defaults? I mean, you can just have a single line of code "if lo is None: lo = 0" and it'd be fine. Why do we need the ability to put "lo=0" in the signature? I put it to you that the same justification should be valid for hi. ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/PC27XLYJVIC4TXHYJN5XLMR2ZQQLMVT5/ Code of Conduct: http://python.org/psf/codeofconduct/