class Shape:

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

  def get_area( self):
    return 0


class Rectangle( Shape):

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

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


class Circle( Shape):

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

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


class Text:

  def __init__( self, color, text):
    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!")

print hasattr( o1, "color")
if hasattr( o3, "color"):
  print getattr( o3, "color")
  print o3.color

if hasattr( o4, "text"):
  print o4.text
  setattr( o4, "text", "New text")
  print o4.text

print getattr( o2, "get_area")
print getattr( o2, "get_area")()

for o in [o1,o2,o3,o4]:
  if hasattr( o, "get_area"):
    print "%s has area %d" % (o, getattr( o, "get_area")())
  else:
    print "%s does not support area" % o
