Then may be we could enhance "filter" or introduce some alias? Why we have "filterfalse" and don't have "filtertrue"?Thanks!Stepan Dyatkovskiy 14.09.2021, 22:20, "Chris Angelico" :On Wed, Sep 15, 2021 at 4:58 AM Tim Peters wrote: Or perhaps the `compress()` implementation cou
On Wed, Sep 15, 2021 at 4:58 AM Tim Peters wrote:
> Or perhaps the `compress()` implementation could grow internal
> conditionals to use a different algorithm if the second argument is
> omitted. But that would be a major change to support something that's
> already easily done in more than one mo
On Tue, 14 Sept 2021 at 19:58, Tim Peters wrote:
> Except it's not that simple:
Apologies, Tim, it took me a couple of reads to work out what you were
saying here. I hope you won't mind if I restate the point for the
benefit of anyone else who might have got confused it like I did...
> def
[Chris Angelico ]
> ...
> For it to be accepted, you have to convince people - particularly,
> core devs - that it's of value. At the moment, I'm unconvinced, but on
> the other hand, all you're proposing is a default value for a
> currently-mandatory argument, so the bar isn't TOO high (it's not l
On Wed, Sep 15, 2021 at 4:03 AM m...@dyatkovskiy.com
wrote:
>
> > The signature is wrong.
> Thanks for remark. Of course proper signature would be:
>
> def jin(a: Iterable[Optional[str]], sep=“ “):
> # …
>
> > Why do you (ab)use compress for that?
> Well, it seems that it is subjective. To me
> The signature is wrong.
Thanks for remark. Of course proper signature would be:
def jin(a: Iterable[Optional[str]], sep=“ “):
# …
> Why do you (ab)use compress for that?
Well, it seems that it is subjective. To me “[None, x, y, z]” -> “[x, y, z]”
looks like “compression”. But if community
On Tue, Sep 14, 2021 at 11:31:43AM +0400, m...@dyatkovskiy.com wrote:
> Thus I have collection of options and some of them are empty or None.
> In order to get rendered command line options string I use “compress”
> in conjunction with “join":
>
> >>> opts = " ".join(compress(flags, flags))
Wh
On Tue, 14 Sept 2021 at 08:38, m...@dyatkovskiy.com
wrote:
> Main motivation was a use case where we gather command line options, and some
> of them are… optional.
[...]
> And yet I’m solid that we need some compact and nice way for rendering
> strings with command options. That would be a thin
OK, If I might tell some story... :)
Main motivation was a use case where we gather command line options, and some
of them are… optional.
Below is a realistic example. Namely options for LLVM Clang:
>>> flags = [“-O3”, “-fomit-frame-pointer”, maybe_pgo(context)]
Here “maybe_pgo” returns either
FYI, itertools.compress() is very useful in conjunction with
itertools.cycle() to pick out elements following a periodic pattern of
indices. For example,
# Elements at even indices.
>>> list(compress(range(20), cycle([1, 0])))
[0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
# Or at odd ones.
>>> list(compres
I've never used compress() either. But I probably HAVE selected only the
"truthy" elements of an iterable. The obvious way to do that is:
it = (x for x in it if x)
It feels like changing compress() would just be more obscure, but not add
to clarity.
On Mon, Sep 13, 2021, 5:07 PM Rob Cliffe via P
My 2c:
I don't remember ever seeing itertools.compress (although I've
occasionally browsed through itertools), and I've certainly never used
it. However, having worked out what it does, my first reaction was that
this would be a harmless and mildly convenient change. But might it not
lead to
You can already do this using filter(None, a)
>>> list(filter(None, [None, "", "-filove-python", "CFLAGS=-O3"]))
['-filove-python', 'CFLAGS=-O3']
There's arguably a minor readability improvement (compress(a) suggests
"remove the unneeded elements") but I'm not sure that's enough to
justi
13 matches
Mail list logo