> That's a matter of taste. Try replacing the try...except block with
> hasattr:
>
> def doStuff():
>     if hasattr(doStuff, timesUsed):
>         doStuff.timesUsed += 1
>     else:
>         doStuff.timesUsed = 1
>     do_common_code
>

Ok, it is a matter of taste and I prefer the try/except way, but with
hasattr you will do a function call and a intern 'truthness'
verification each time you increment .timeUsed. With try/except, after
the first time, you do nothing else than increment it.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to