Another two examples of using changing classes

Andrew Dalke dalke at acm.org
Mon Aug 13 17:32:35 EDT 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?
  http://www.cwi.nl/www.python.org/search/hypermail/python-1992/0293.html

] 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).

<wink>

(Ahh, behold the power of Google to dreg up old words. :)

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list