def cdataescape(s):
 if isinstance(s, unicode):
  s = s.encode('utf-8')
 parts = s.split(']]>')
 return ']]]]><![CDATA[>'.join(parts)

def cdataescape ( s ) : if isinstance ( s , unicode ) : s = s . encode ( 'utf-8' ) parts = s . split ( ']]>' ) return ']]]]><![CDATA[>' . join ( parts )
return the string escaped for inclusion in an xml cdata section .