<div dir="ltr">Dismiss my message, I have read `if "art_wt" not in article`. But in the same way, you could have a function to reset a value in your dict if the current value evaluates to False.</div><div class="gmail_extra"><br><div class="gmail_quote">2018-05-26 11:21 GMT+02:00 Antoine Rozo <span dir="ltr"><<a href="mailto:antoine.rozo@gmail.com" target="_blank">antoine.rozo@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class="">> if not article["art_wt"]: article["art_wt"] = 0<div>> if not article["px_pchs"]: article["px_pchs"] = 0</div><div>> if not article["px_calc"]: article["px_calc"] = 0</div><div>> if not article["px_sell"]: article["px_sell"] = 0</div><div><br></div></span><div>I think what you need is the setdefault method of dictionnaries, instead of a new syntax construct.</div></div><div class="gmail_extra"><div><div class="h5"><br><div class="gmail_quote">2018-05-26 1:52 GMT+02:00 Carl Smith <span dir="ltr"><<a href="mailto:carl.input@gmail.com" target="_blank">carl.input@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">You cannot have `expression if expression` in a language that also supports</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">`expression if expression else expression` (like Python). Otherwise, you have</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)">the dangling else problem:</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small;color:rgb(0,0,0)"><br></div><div class="gmail_default"><font color="#000000" face="verdana, sans-serif"><a href="https://en.wikipedia.org/wiki/Dangling_else" target="_blank">https://en.wikipedia.org/wiki/<wbr>Dangling_else</a></font><span class="m_-9123474387121577133HOEnZb"><font color="#888888"><br></font></span></div></div><div class="gmail_extra"><span class="m_-9123474387121577133HOEnZb"><font color="#888888"><br clear="all"><div><div class="m_-9123474387121577133m_-5911127467685300768gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><span style="color:rgb(115,115,115);font-style:italic;line-height:18px"><font size="1" face="monospace, monospace">-- Carl Smith</font></span><br></div></div><div><span style="color:rgb(115,115,115);font-style:italic;line-height:18px"><font size="1" face="monospace, monospace"><a href="mailto:carl.input@gmail.com" target="_blank">carl.input@gmail.com</a></font></span></div></div></div></div></div></div></font></span><div><div class="m_-9123474387121577133h5">
<br><div class="gmail_quote">On 25 May 2018 at 15:21, Rob Cliffe via Python-ideas <span dir="ltr"><<a href="mailto:python-ideas@python.org" target="_blank">python-ideas@python.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><br>
<br>
On 25/05/2018 12:38, Steven D'Aprano wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
PEP 8 is not holy writ. Ignore it when your code is better for ignoring<br>
it.<br>
<br>
<br>
</blockquote></span>
+1. Not infrequently I judge that my code is easier both to read and to maintain with more than 1 (short) statement on a line,<br>
often when it allows similar items to be aligned vertically. A spur-of-the moment, totally invented example:<br>
if MON <= day <= FRI: Rate = Normal<br>
if day==SAT: Rate = DoubleTime<br>
if day==SUN: Rate = TripleTime<br>
I also feel no inhibitions about using Jacco's original example:<br>
if cond: do_something<span class="m_-9123474387121577133m_-5911127467685300768HOEnZb"><font color="#888888"><br>
Rob Cliffe</font></span><div class="m_-9123474387121577133m_-5911127467685300768HOEnZb"><div class="m_-9123474387121577133m_-5911127467685300768h5"><br>
______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
</div></div></blockquote></div><br></div></div></div>
<br>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/python-ideas</a><br>
Code of Conduct: <a href="http://python.org/psf/codeofconduct/" rel="noreferrer" target="_blank">http://python.org/psf/codeofco<wbr>nduct/</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div class="m_-9123474387121577133gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Antoine Rozo</div></div>
</font></span></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Antoine Rozo</div></div>
</div>