Is this pythonic?

Marko Rauhamaa marko at pacujo.net
Wed Nov 23 04:50:14 EST 2016


"Frank Millman" <frank at chagford.com>:

> 3. When instantiating an object, check if it would need computation -
>    if computation_required:
>        self.getval = self._getval_with_comp
>    else:
>        self.getval = self._getval
>
> 4. In _getval_with_comp, perform the computation, then add the following -
>        self.getval = self._getval
>        return self._getval()
>
> What is the verdict? -1, 0, or +1?

Perfectly cromulent, run-of-the-mill Python code.


Marko



More information about the Python-list mailing list