4 ms·
Define a function to do the same and call that at the end of every method? These don't seem that different to me: def doStuff(): # do stuff
by jdmichal 10y ago
Define a function to do the same and call that at the end of every method? These don't seem that different to me:
def doStuff():
# do stuff
return checkError(value)
@checkError
def doStuff():
# do stuff
return value
EDIT: In fact, I think the above succinctly hits on lotsoflumens' point. The latter clearly obfuscates the fact that an error check is performed behind the decorator. The former makes it very clear that something is happening to the return value before it leaves.