How to implement CRTP functionality in python?
问题 I want to access a member (variable) of a derived class from a base class in python. In c++ I can use the CRTP design pattern for this. In c++, for example, I would do something like this: #include <iostream> template <class derived> class Base { public: void get_value() { double value = static_cast<derived *> (this) -> myvalue_; std::cout<< "This is the derived value: " << value << std::endl; } }; class derived:public Base<derived>{ public: double myvalue_; derived(double &_myvalue) {