[Python-Dev] Monkeypatching idioms -- elegant or ugly? (original) (raw)
glyph at divmod.com glyph at divmod.com
Tue Jan 15 16:59:53 CET 2008
- Previous message: [Python-Dev] Monkeypatching idioms -- elegant or ugly?
- Next message: [Python-Dev] Monkeypatching idioms -- elegant or ugly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 03:37 pm, guido at python.org wrote:
I think it's useful to share these recipes, if only to to establish whether they have been discovered before, or to decide whether they are worthy of a place in the standard library. I didn't find any relevant hits on the ASPN Python cookbook.
from import
class (): metaclass = monkeypatchclass def (...): ... def (...): ... ...
I've expressed this one before as "class someclass(reopen(someclass)):", but have thankfully never needed to actually use that in a real program. It's been a helpful tool in explaining to overzealous Ruby-ists that "reopenable" classes are not as unique as they think.
My feelings on monkeypatching is that it should feel a little gross when you have to do it, so the code I've written that does monkeypatching for real is generally a bit ugly.
- Previous message: [Python-Dev] Monkeypatching idioms -- elegant or ugly?
- Next message: [Python-Dev] Monkeypatching idioms -- elegant or ugly?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]