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
justify the change. On the other hand, it's not like there's any
obviously better default value for the second argument...

I guess overall I'm fairly indifferent to the change.
Paul

On Mon, 13 Sept 2021 at 13:07, <[email protected]> wrote:
>
> Hi!
>
> I propose to enhance "itertools.compress" in such a way so if you don't 
> provide selectors, then "data" itself is used as a selectors.
> So "compress(a)" would be equivalent to "compress(a, a)"
>
> For example:
>
> >>> from itertools import compress
>
> >>> [*compress([0, 1, 2, 3]))]
> [1, 2, 3]
>
> >>> [*compress(["", "CFLAGS=-O3"])]
> ["CFLAGS=-O3"]
>
> >>> opts = compress([None, "", "-filove-python",  "CFLAGS=-O3"])
> >>> " ".join(opts)
> '-filove-python CFLAGS=-O3'
>
> What do you think guys about this? Perhaps it was proposed by someone else?
>
> Thanks!
> Stepan Dyatkovskiy
> _______________________________________________
> Python-ideas mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-ideas.python.org/
> Message archived at 
> https://mail.python.org/archives/list/[email protected]/message/LVD63OEWRTTU542NKFODLERXCM7LEQ5D/
> Code of Conduct: http://python.org/psf/codeofconduct/
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/GKJWM6K26OO2NMO6VUK4P3CDUEC6MDAJ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to