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
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
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
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
On Tue, Jun 07, 2022 at 02:28:51PM -, [email protected] 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
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