[Tutor] Changing a class into a subclass

Ismael Garrido ismaelgf at adinet.com.uy
Thu Mar 24 18:07:31 CET 2005


Hello.

I have a program that saves/loads to/from XML. I have a main class 
Building, and a subclass House(Building). When I save the code I 
instruct each object to save itself to XML (using ElementTree), so House 
adds itself to the XML tree.
My problem is when I load the XML. Before having subclasses what I did 
was to send the XML object (again in ElementTree) to the object and let 
itself load. Now, with subclasses, if I send the House XML to Building I 
get a Building instance, when I need a House instance.

I couldn't figure out a way to make a Building instance turn into a 
House instance. Is there any way? Or I'll just have to rewrite the whole 
XML loading scheme and have a particular function doing all the loading?

Thanks for any help.
Ismael


More information about the Tutor mailing list