C-style static variables in Python?
no.email at please.post
Fri Apr 2 18:59:00 EDT 2010
In <Xns9D4EC021DC8EAduncanbooth at 127.0.0.1> Duncan Booth <duncan.booth at invalid.invalid> writes:
> mongo = None
> def __call__(self, x, y, z):
> if self.mongo is None:
> self.mongo = heavy_lifting_at_runtime()
> return frobnicate(x, y, z, self.mongo)
>spam = Spam()
>ham = spam(1, 2, 3)
I really like this. Thanks.
>That's natural and readable.
>From reading this thread, and the "(a==b) ? 'Yes' : 'No'" one, the
inescapable conclusion is that "readability" (like beauty) is very
much in the eye of the beholder, or, in this case, in the eye of
More information about the Python-list