[Python-Dev] Monkeypatching idioms -- elegant or ugly?

Guido van Rossum guido at python.org
Tue Jan 15 22:51:25 CET 2008


On Jan 15, 2008 1:27 PM, "Martin v. Löwis" <martin at v.loewis.de> wrote:
> > Second, a "metaclass" to add a number of methods (or other attributes)
> > to an existing class, using a convenient class notation:
>
> I think this is similar to my "partial" classes:
>
> http://pypi.python.org/pypi/partial

Indeed it is. I guess my only innovation is realizing that you don't
have to create a real metaclass -- you can set __metaclass__ to a
function that does the magic. I like your feature of refusing
overrides unless flagged with @replace.

I think that despite the objection that monkeypatching shoudn't be
made too easy, it's worth at looking into a unification of the API,
features, and implementation.

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-Dev mailing list