<html>
<body>
At 10:30 AM 3/24/2005, Max Noel wrote:<br><br>
<blockquote type=cite class=cite cite="">On Mar 24, 2005, at 18:07,
Ismael Garrido wrote:<br><br>
<blockquote type=cite class=cite cite="">Hello.<br><br>
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.<br>
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.</blockquote><br>
<x-tab>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</x-tab>You can't
make an object transform into an object of a different
class</blockquote><br>
Are you referring to a Python object? If so you may assign a class to the
object's __class__ attribute.<br>
class A:pass<br>
class B:pass<br>
b = b()<br>
print b.__class__ # displays &lt;class __main__.B at 0x011BB9C0&gt;<br>
b.__class__ = A<br>
print b.__class__ # displays &lt;class __main__.A at
0x011BBA20&gt;<br><br>
[snip]<br>
<x-sigsep><p></x-sigsep>
<font size=2>Bob Gailer<br>
<a href="mailto:bgailer@alum.rpi.edu" eudora="autourl">mailto:bgailer@alum.rpi.edu<br>
</a>510 558 3275 home<br>
720 938 2625 cell</font> </body>
</html>