> One solution is to use descriptor protocol on the class, which means > using a metaclass. I'm not sure it's the best option, but it is an > option.
I will look at that, I wonder if however I am not over complicating it: class Foo: _bar = None @property def expensive(self): if Foo._bar is None: import something Foo._bar = something.expensive() return Foo._bar Somewhat naive, but a test with if is pretty cheap... Thanks Chris, jlc -- https://mail.python.org/mailman/listinfo/python-list