[Python-Dev] Monkeypatching idioms -- elegant or ugly? (original) (raw)
Guido van Rossum guido at python.org
Thu Jan 31 20:50:51 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 Jan 31, 2008 9:49 AM, nathan binkert <nate at binkert.org> wrote:
Another thing about monkeypatching is that it seems like the best way to write an extension class where you want half to be in C/C++ and half in Python. I'm in the middle of working on such a class and there are plenty of members that just don't need to be in C++.
Is there a better/preferred idiom for such a thing? I don't want to subclass my new class because I want any objects created on the C++ side to also get the python methods.
Have you tried this? I believe it doesn't even work; types defined in C++ are supposed to be immutable. Try adding a new method to list or dict.
However the C++ side should be able to create instances of the Python-defined subclass as long as it runs in a method, since it has a reference to the actual class.
-- --Guido van Rossum (home page: http://www.python.org/~guido/)
- 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 ]