In article <mailman.939.1243725387.8015.python-l...@python.org>, Gabriel <gabr...@opensuse.org> wrote: > >I have something like this: > >@render(format="a") >@render(format="b") >@.... >def view(format, data): > return data > >Each render will do something with 'data' if format match, and nothing >if not. > >But if there is no more renders to eval, the last one is the default, >and must run even if the format doesn't match.
My inclination would be to make this explicit with something like this: def make_render(func, format_list): def tmp(format, data): for f in format_list: if MATCH(format, f): render(data) break else: render(data) return tmp def view(format, data): return data view = make_render(view, ['a', 'b']) IOW, just because we have decorators doesn't mean that they're the best solution for all function-wrapping problems. -- Aahz (a...@pythoncraft.com) <*> http://www.pythoncraft.com/ my-python-code-runs-5x-faster-this-month-thanks-to-dumping-$2K- on-a-new-machine-ly y'rs - tim -- http://mail.python.org/mailman/listinfo/python-list