[Python-Dev] Monkeypatching idioms -- elegant or ugly? (original) (raw)

Nicko van Someren nicko at nicko.org
Sat Jan 19 18:19:43 CET 2008


On 15 Jan 2008, at 15:37, Guido van Rossum wrote:

Second, a "metaclass" to add a number of methods (or other attributes) to an existing class, using a convenient class notation: ... class (): metaclass = monkeypatchclass def (...): ... def (...): ... ...

In Objective-C it's perfectly common to extend existing classes using
'categories' and I have often found this idiom very useful. What is
described here is basically categories for Python. I've implemented
something like this before and I would be happy to see this added to
the standard library and formalised.

Nicko


More information about the Python-Dev mailing list