[Python-ideas] Re: default as a keyword argument for dict.get and dict.pop

2022-06-07 Thread Chris Angelico
On Wed, 8 Jun 2022 at 00:36, wrote: > > Hello! > > Do you know if there has been discussions around why is the default argument > is positional only in the dict methods get and pop? > > I think > > ``` > d.get(key, default=3) > ``` > > way more readable than > > ``` > d.get(key, 3) > ``` > > spec

[Python-ideas] Re: default as a keyword argument for dict.get and dict.pop

2022-06-07 Thread Steven D'Aprano
On Tue, Jun 07, 2022 at 02:28:51PM -, martineznicolas41...@gmail.com wrote: > Do you know if there has been discussions around why is the default > argument is positional only in the dict methods get and pop? Its probably just left over from earlier versions of Python when builtin functions

[Python-ideas] default as a keyword argument for dict.get and dict.pop

2022-06-07 Thread martineznicolas41541
Hello! Do you know if there has been discussions around why is the default argument is positional only in the dict methods get and pop? I think ``` d.get(key, default=3) ``` way more readable than ``` d.get(key, 3) ``` specially since max and min builtin functions use default as a keyword a

[Python-ideas] Re: Addition to fnmatch.py

2022-06-07 Thread MRAB
On 2022-06-07 11:03, Chris Angelico wrote: On Tue, 7 Jun 2022 at 19:09, Ben Rudiak-Gould wrote: This calls the predicate once per element: def partition(pred, iterable): t1, t2 = tee((pred(x), x) for x in iterable) return (x for b, x in t1 if not b), (x for b, x in t2 if b

[Python-ideas] Re: Addition to fnmatch.py

2022-06-07 Thread Chris Angelico
On Tue, 7 Jun 2022 at 19:09, Ben Rudiak-Gould wrote: > > This calls the predicate once per element: > > def partition(pred, iterable): > t1, t2 = tee((pred(x), x) for x in iterable) > return (x for b, x in t1 if not b), (x for b, x in t2 if b) > > It's kind of inefficient thoug

[Python-ideas] Re: Addition to fnmatch.py

2022-06-07 Thread Ben Rudiak-Gould
This calls the predicate once per element: def partition(pred, iterable): t1, t2 = tee((pred(x), x) for x in iterable) return (x for b, x in t1 if not b), (x for b, x in t2 if b) It's kind of inefficient though. ___ Python-ideas mail