strategy pattern and non-public virtual functions
John J. Lee
jjlee at reportlab.com
Mon Jun 5 15:47:03 EDT 2006
pythoncurious at gmail.com writes:
> Hi python experts
>
> In C++ I can do something like this:
> class Base {
> public:
> void f() { this->f_(); }
> private:
> virtual void f_() = 0;
> };
>
> class Derived : public Base {
> private:
> void f_() { // Do something }
> };
>
> int main() {
> Derived d;
> d.f();
> }
[...]
The others have already answered the Python question and pointed out
this isn't really the Strategy Pattern.
Still, these slides from Alex Martelli specifically on the Template
Method DP in Python are probably very relevant to you:
http://www.aleax.it/Python/os03_template_dp.pdf
John
More information about the Python-list
mailing list