Source formatting for long expressions.

Christopher Armstrong radix at twistedmatrix.com
Tue Jun 11 10:32:46 EDT 2002


>>>>> "sameer" == sameer  <sameer_ at email.com> writes:

    sameer> why not just do it in xml?  

Twisted already has an XML persistence mechanism, and that is exactly what
inspired me (with disgust) to write AOT (this source-persistence mechanism). 
AOT is better in every possible respect than the XML persistence IMNSHO, save 
for the fact that it requires (minimal) understanding of Python syntax,
and the format for References is _slightly_ uglier (Ref(num, obj) -- since not
every object is represented with a "tag" (or class call), I can't insert
reference numbers "into" arbitrary objects).

XML is a terrible format for object persistence, due to the lack of robust
mappings. Twisted's XML uses attributes in some cases, but that is only
possible when you have string:string mappings. In *any* other case, you
have to resort to children nodes, with such ugly syntax as::

<instance class="twisted.some.Class">
<dictionary>
  <string role="key" value="someAttr" />
  <list>
    <string value="foo" />
  </list>
</dictionary>

Compare that with the equivalent AOT format::

Instance("twisted.some.Class", 
  someAttr=["foo"],
)

*That* is why I don't just use XML.

-- 
                                Chris Armstrong
                         << radix at twistedmatrix.com >>
                http://twistedmatrix.com/users/carmstro.twistd/






More information about the Python-list mailing list