title: is there a way to check if a class instance attribute is itself a class instance
body: <p>I'm trying to serialize a python complex class instance to xml however I can't figure out how to determine if any of it's attributes are class instances this is my code.</p>
  <pre><code>def serialize_model_to_XML(self, modelObject, tagName):
      xml = etree.Element(tagName)
      for attribName, value in modelObject.__dict__.items():
          if isinstance(value, type) == '__builtin__': #this line needs to determine if the value of the class attribute is a class instance
              tagElement = self.serialize_model_to_XML(value, attribName)
              xml.append(etree.Element(tagElement))
          else:
              #if not then the key value pair is added as an attribute to the current tag
              xml.attrib[attribName] = value
  
      return xml
  </code></pre>