Another two examples of using changing classes
dalke at acm.org
Mon Aug 13 23:32:35 CEST 2001
Terry Reedy wrote:
>A third way is to have a 'connected' variable and make every function
>conditional on the state variable. Changing class is much cleaner.
Perhaps similar to this post from guido at cwi.nl in 1992?
] Suppose we have a class whose objects have some kind of state which
] modifies the meaning of one or more methods. Traditionally this is
] done by changing a flag which is tested by the affected methods.
] A variant would require that an instance's __class__ attribute be
] writeable [...] In fact the mere possibility of this makes me
] doubt the read-only-ness of __class__ (or __bases__, for that matter).
(Ahh, behold the power of Google to dreg up old words. :)
dalke at dalkescientific.com
More information about the Python-list