
Sept. 9, 2016
8:01 p.m.
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") pozdrawiam, Arkadiusz Bulski