Mac wrote: > * using > def debug_emit(obj): > if debug: > emit_dbg_obj(obj) > is a poor solution, because it *always* instantiates DbgObj*, even when > not needed; I want to avoid such unnecessary waste
Rather than passing in an instantiated object and only operating on it if the debug flag is set, how about passing in the class & initialisation parameters and only creating the object if necessary? >>> def debug_emit(cls, args): ... if debug: emit_dbg_obj(cls(*args)) Then your calls will just be a single line: >>> debug_emit(DbgObjFoo,(a,b,c)) Does that help at all? -alex23 -- http://mail.python.org/mailman/listinfo/python-list