A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2008-January/076311.html below:

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

[Python-Dev] Monkeypatching idioms -- elegant or ugly? [Python-Dev] Monkeypatching idioms -- elegant or ugly?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 <newclass>(<someclass>):
>    __metaclass__ = monkeypatch_class
>    def <method1>(...): ...
>    def <method2>(...): ...
>    ...

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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4