23 Jan
2014
23 Jan
'14
9:52 a.m.
On Thursday 23 January 2014 02:57 PM, David Townshend wrote:
Not a decorator, but you can monkey patch it:
@wraps(smtplib.SMTP.sendmail) def sendmail(*args, **kwargs): other_function() return smtplib.SMPT.sendmail(*args, **kwargs)
smtplib.SMTP.sendmail = sendmail
Correct. I want to say something like: from functools import prepostcall smtplib.SMTP.sendmail = prepostcall(smtplib.SMTP.sendmail) smtplib.SMTP.sendmail.before.append(other_function) This seems less error-prone. And more conducive to multiple patching.