Setting metaclass of wrapped class with Boost.Python
问题 I have an Event class defined in C++ that I expose to Python using Boost. My scripts are expected to derive from this class, and I'd like to do some initialization whenever a new child class is defined. How can I set the metaclass of the exposed Event class such that whenever a Python script derives from this class, the metaclass could do the required initialization? I would like to avoid having to explicitly use a metaclass in the scripts... class KeyboardEvent(Event): # This is what I want