class DefinedObject(object):
    pass

from StringIO import StringIO

class DefinedObject(object):

    def to_xml(self):
        """Export an object as an XML String"""

        s = StringIO()
        self.to_obj().export(s, 0)
        return s.getvalue()

Add utility method to DefinedObject base class
Add utility method to DefinedObject base class

+ from StringIO import StringIO
+ 
  class DefinedObject(object):
-     pass
  
+     def to_xml(self):
+         """Export an object as an XML String"""
+ 
+         s = StringIO()
+         self.to_obj().export(s, 0)
+         return s.getvalue()
+ 
Add utility method to DefinedObject base class
## Code Before:
class DefinedObject(object):
    pass

## Instruction:
Add utility method to DefinedObject base class
## Code After:
from StringIO import StringIO

class DefinedObject(object):

    def to_xml(self):
        """Export an object as an XML String"""

        s = StringIO()
        self.to_obj().export(s, 0)
        return s.getvalue()
