Changing class membership

Dirk-Ulrich Heise hei at adtranzsig.de
Wed Sep 27 10:49:49 EDT 2000


How do i most elegantly let an object switch its class
membership? My problem is, i have a sort of proxy object
with a name. When this proxy object gets a certain request
(especially, for a text it represents), it can't answer this
request because it doesn't have the info. But it knows
where to look on the harddisk, so it will load this text,
magically become a "real object" (no more a proxy, but
now a full-fitted object that has all its info), and answer the
request.

On later requests, it will have forgotten about it's infant
proxy status but simply tell everybody the info it has now.

I guess that's called "switching modes". Hmm. Maybe,
for now i'll simply switch with a bool member. Anyway,
somebody used mode switching out there? Pros?
Cons? Advice for this design decision?

--
Dipl.Inform. Dirk-Ulrich Heise
hei at adtranzsig.de
dheise at debitel.net







More information about the Python-list mailing list