On Thu, 16 Dec 2010 20:32:29 -0800, Carl Banks wrote: > Even without the cleanup issue, sometimes you want to edit a function to > affect all return values somehow. If you have a single exit point you > just make the change there; if you have mulitple you have to hunt them > down and change all of them--if you remember to. I just got bit by that > one.
If your function has so many exit points that you can miss some of them while editing, your function is too big, does too much, or both. Refactor and simplify. Or wrap the function in a decorator: def affect_all_return_values(func): @functools.wraps(func) def inner(*args, **kwargs): result = func(*args, **kwargs) do_something_to(result) return result return inner @affect_all_return_values def my_big_complicated_function(args): do_something_with_many_exit_points() -- Steven -- http://mail.python.org/mailman/listinfo/python-list