Python Patterns
Jacek Generowicz
jacek.generowicz at cern.ch
Wed Oct 6 04:11:56 EDT 2004
aleaxit at yahoo.com (Alex Martelli) writes:
> Irmen de Jong <irmen at -nospam-remove-this-xs4all.nl> wrote:
> > This "state" pattern needs a clumsy internal state object in C++
> > but in Python we can just change the object's class directly,
> > which is a much more direct implementation of what the pattern
> > tries to achieve :-)
>
> Right, good point. In C++ you can do something closer with the Strategy
> pattern -- still one level of indirectness, but a consistent set of
> methods (embodied in the one strategy object) commuted as a whole.
> Assigning __class__ IS of course more direct, yes;-).
Isn't Strategy more like rebinding the methods of a class, rather than
rebinding the .__class__ of an instance ?
More information about the Python-list
mailing list