The title is misleading - this has nothing to do with the conditional operator, except small syntactic similarity. <div><div dir="auto"><br></div><div dir="auto">Elazar <br><br><div class="gmail_quote"><div dir="ltr">בתאריך יום ו׳, 25 במאי 2018, 05:40, מאת Jacco van Dorp ‏<<a href="mailto:j.van.dorp@deonet.nl">j.van.dorp@deonet.nl</a>>:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">2018-05-25 14:26 GMT+02:00 Kirill Balunov <<a href="mailto:kirillbalunov@gmail.com" target="_blank">kirillbalunov@gmail.com</a>>:<br>
> If it is an expression, what should `do_something if cond` return on<br>
> failure? If you don't care you can already use `cond and do_something`.<br>
<br>
Duh, forgot to mention.<br>
I wouldn't have it return anything. Ternary returns something because<br>
you have two options and picks one. This is conditional execution of a<br>
statement. I guess it would be a statement, like normal if.<br>
<br>
I guess cond and do_something would be equivalent, but that's not<br>
really the intention of and/or, no matter how much it's used for this<br>
sort of thing.<br>
<br>
Disclaimer:<br>
I don't really expect this to be accepted. It's more of a minor gripe<br>
i've occasionally had. This afternoon, I wrote:<br>
<br>
if not article["art_wt"]: article["art_wt"] = 0<br>
if not article["px_pchs"]: article["px_pchs"] = 0<br>
if not article["px_calc"]: article["px_calc"] = 0<br>
if not article["px_sell"]: article["px_sell"] = 0<br>
<br>
while preparing a dict for import in accountview. I try not to make a<br>
habit of dismissing syntax warnings. I consider the code above<br>
abundantly clear (no, I dont know what those keys mean. Since I have<br>
no power over that, I dont consider it detrimental to clarity.)<br>
_______________________________________________<br>
Python-ideas mailing list<br>
<a href="mailto:Python-ideas@python.org" target="_blank">Python-ideas@python.org</a><br>
<a href="https://mail.python.org/mailman/listinfo/python-ideas" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofconduct/</a><br>
</blockquote></div></div></div>