On Fri, 2008-03-14 at 23:01 +0100, Duncan Webb wrote: > Log: > The level needs to be come from a singleton class
You might consider looking at kaa.utils.Singleton if you need a singleton. Though I'm not sure you do here. > Not sure about the __incr__ and __decr__ functions :-/ You're right to be apprehensive about this. :) Use __foo__ only for actual special methods, among which __incr__ and __decr__ are not. They are defined at http://docs.python.org/ref/specialnames.html . Something like inc() and dec() would be better. I think though you might have overengineered this solution. Why not just make level a class variable instead of an instance variable? Then it is shared among all instances. class timed: level = 0 def __call__(self, func): timed.level += 1 try: [...] finally: timed.level -= 1 Note that with your current code if func() raises an exception, level will not get decremented. Also note that kaa has a decorator called timed that does something entirely different, so you might consider instead renaming your decorator to benchmark. That way if you ever decide to use kaa.timed() it won't be utterly confusing. :) Cheers, Jason. ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ Freevo-devel mailing list Freevo-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/freevo-devel