On Jun 7, 2012, at 2:42 PM, Cliff Kachinske wrote: > I don't have a good feel for the most efficient way to, for example, pass the > db to a class method. I can think of three ways. > > - Pass it in when you call the method. > - Pass it in when you initialize the class > - Import current, do something like current.db = db and then pass current to > the class's __init__ > > Any opinions on this? All help greatly appreciated.
It shouldn't really matter. But where is the caller and callee? If the caller is in a controller and the callee is in an imported module, for example, I don't think it makes much difference. I'd avoid current where you don't really need it (and if you do use current, using current.db is a little risky; try to give yourself a safe namespace).