
On Fri, Sep 9, 2016 at 3:01 PM, Arek Bulski <arek.bulski@gmail.com> wrote:
Sometimes I find myself in need of this nice operator that I used back in the days when I was programming in .NET, essentially an expression
expr ?? instead
should return expr when it `is not None` and `instead` otherwise.
A piece of code that I just wrote, you can see a use case:
def _sizeof(self, context): if self.totalsizeof is not None: return self.totalsizeof else: raise SizeofError("cannot calculate size")
With the oprator it would just be
def _sizeof(self, context): return self.totalsizeof ?? raise SizeofError("cannot calculate size")
This was proposed almost exactly a year ago, start reading here: https://mail.python.org/pipermail/python-ideas/2015-September/036289.html -- Zach