skipping __init__ and using exploiting a class member instead
Devin Jeanpierre
jeanpierreda at gmail.com
Sun Oct 20 10:27:27 EDT 2013
On Sat, Oct 19, 2013 at 2:44 PM, Peter Cacioppi
<peter.cacioppi at gmail.com> wrote:
> Is the following considered poor Python form?
>
> class Foo (object) :
> _lazy = None
> def foo(self, x) :
> self._lazy = self._lazy or self.get_something(x)
> def get_something(self, x) :
> # doesn't really matter
>
> I like this idiom for certain situations, just wondering if it will raise the hackles of other Pythonistas.
It raises my hackles, but not for any good reason.
I've seen it a number of times in the Twisted codebase, so you're not
alone in using it.
-- Devin
More information about the Python-list
mailing list