
Dec. 8, 2019
7:30 p.m.
On 8 Dec 2019, at 20:11, Guido van Rossum <guido@python.org> wrote:
On Sun, Dec 8, 2019 at 11:03 AM Anders Hovmöller <boxed@killingar.net> wrote:
On 8 Dec 2019, at 19:40, Guido van Rossum <guido@python.org> wrote:
def first(it, /, default=None): it = iter(it) try: return next(it) except StopIteration: return default
Why ban the use of keyword argument for the default value?
You must misremember PEP 570. This use of `/` means that `it` must be passed positional (it's mandatory and it's the "main" argument), but that `default` can be specified positionally or via a keyword.
Ah. Sorry. My bad.