[Python-ideas] __metafunc__

Zac Burns zac256 at gmail.com
Wed Mar 17 21:31:20 CET 2010


I would like to propose a __metafunc__ that would work similar to
metaclasses but for functions.

My use case is for duck punching all functions defined in a module.  This
tends to be difficult as a postprocess after __import__ (you have to modify
method.im_func and deal with closures and functions in the module namespace
that might be references to functions defined elsewhere - it's a mess).

If instead when defining a function it did a lookup of __metafunc__ and
called it (like a decorator) after a function was defined then I could
import the module in a globals that includes my __metafunc__.

Feel free to tear this idea apart, improve it, or dash it on the rocks.
Perhaps some of you will also see use cases for this or something like it?

--
Zachary Burns
(407)590-4814
Aim - Zac256FL
Production Engineer (Digital Overlord)
Zindagi Games
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20100317/ecb77afe/attachment.html>


More information about the Python-ideas mailing list