On Tue, 14 Sept 2021 at 08:38, m...@dyatkovskiy.com <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 thing.

Frankly, I'd just use something like your "jin" function

def make_option_string(options):
    return " ".join(opt for opt in options if opt)

Note that I gave it a more readable name that reflects the actual use
case. This is deliberate, as I think the main advantage here is
readability, and using a name that reflects the use case, rather than
a "generic" name, helps readability. That's also why I don't see this
as being a useful candidate for the stdlib - it would have to have a
"generic" name in that case, which defeats the (for me) main benefit.

I find the "sep.join(x for x in it if x)" construction short and
readable enough that I'd be unlikely to use a dedicated function for
it, even if one existed. And while "x for x in it if x" is annoyingly
repetitive, it's not so bad that I'd go hunting for a function to
replace it.

So for me, I *don't* think we need a dedicated function for this.

Paul
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/KQNQIJFNPPOKQ7OJ7KMFOSNJDKJIHICV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to