[Python-ideas] __before__ and __after__ attributes for functions
Chris Angelico
rosuav at gmail.com
Thu Jan 23 10:58:05 CET 2014
On Thu, Jan 23, 2014 at 8:52 PM, Suresh V. <suresh_vv at yahoo.com> wrote:
> 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.
Easy. Just replace the import statement with the def that I gave
above, and then it works. Or make your own module of "handy stuff" and
use that. Not everything has to be in the stdlib :)
ChrisA
More information about the Python-ideas
mailing list