2005/6/1, Oleg Broytmann <phd@...>:
> On Wed, Jun 01, 2005 at 08:16:58AM -0400, Kevin Dangoor wrote:
> > Every time you retrieve _connection, your __get__ method will be called=
> And because of that one probably would want to cache the result of
> the expensive calculations.
This works great, thanks for all the help.
I've got another similar question. I've got another class like so:
When I import this class, it has to connect to the database. This is
undesirable for me. What can I do to have it connect lazily? One
thing I was imagining was declaring the class in a function and
sticking it into the module dictionary. I'm not so crazy about that.
The only reason I'm declaring this class X at all is that another
class, Y, let's say, has a foreign key pointing to it.