import xml.dom.minidom as dom

class Shape:

  def __init__( self, color=None):
    self.color = color

  def get_area( self):
    return 0


class Rectangle( Shape):

  def __init__( self, color=None, width=None, height=None):
    Shape.__init__( self, color=color)
    self.width = width
    self.height = height

  def get_area( self):
    return self.width * self.height


class Circle( Shape):

  def __init__( self, color=None, radius=None):
    Shape.__init__( self, color=color)
    self.radius = radius

  def get_area( self):
    return 3.1415 * self.radius**2


class Text:

  def __init__( self, color=None, text=None):
    self.color = color
    self.text = text

# --------------------------------------------------

o1 = Rectangle( "black", 2, 3)
o2 = Rectangle( "yellow", 3, 5)
o3 = Circle( "white", 4)
o4 = Text( "green", "Hello world!")

import pickle

serials = []
for o in [o1,o2,o3,o4]:
  serials.append( pickle.dumps( o))

for serial in serials:
  o = pickle.loads( serial)
  print o, o.__dict__

