<div dir="ltr"><div class="gmail_extra"><div><div class="gmail_signature"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div></div></div></div></div></div></div></div></div></div><div class="gmail_quote">On Mon, Sep 21, 2015 at 3:56 PM, Carl Meyer <span dir="ltr"><<a href="mailto:carl@oddbird.net" target="_blank">carl@oddbird.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
My jaw dropped a bit when I saw it asserted in this thread that<br>
functions returning "useful value or None" is an anti-pattern. I write<br>
functions like that all the time, and I consider it a useful and<br>
necessary Python idiom. I would hate to rewrite all that code to either<br>
deal with exceptions or add default-value-argument boilerplate to all of<br>
them; when "no result" is an expected and normal possibility from a<br>
function, letting the calling code deal with None however it chooses is<br>
much nicer than either of those options.<br></blockquote><div><br></div><div>+1</div><div><br></div><div>Some language features are "prescriptive," designed to encourage particular ways of writing things. Others are "respective," recognizing the variety of ways people write things and respecting that variety. Python has None and generally respects use of it. To say that using None is an anti-pattern is something I would strongly disagree with. Yes, NPE errors are a problem, but eliminating null/None does not eliminate those errors. It merely replaces one common error with an assortment of other errors.</div><div><br></div><div>I like the feature. I have been asking for features like this for years and the number of times I have written the longer forms is too many to count.</div><div><br></div><div>I like the ?.  ?[]  ?()  ?? syntax. I think:</div><div><br></div></div></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>(1) it's strongly related to the . [] () syntax;</div></div></div><div class="gmail_extra"><div class="gmail_quote"><div>(2) any syntax that uses a keyword is either not syntactically related to . [] () or mixes a keyword and punctuation, both of which I dislike;</div></div></div></blockquote><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div class="gmail_extra"><div class="gmail_quote"><div>(3) it's the same syntax as used in other languages (yes, Python is not C# or Dart but there's a good reason Python uses ^ for xor, ** for power, += for add to, etc.)</div></div></div></blockquote><div class="gmail_extra"><div class="gmail_quote"><div><br></div><div>--- Bruce</div></div></div></div>