Allowing Arbitrary Indentation in Python

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Thu Dec 20 01:10:48 EST 2007


En Thu, 20 Dec 2007 00:46:50 -0300, Gary <gfixler at gmail.com> escribió:

> 1) Is it best/more standard to read in, and parse the XML into some
> kind of Python hierarchy first, and then build the UI out of the data
> in that structure, or call out UI commands as say, callbacks from the
> parser live - as it wades through the data? I lean toward the former,
> as it means having one standard set of functions to read in, and parse
> the XML data, which can then be used for anything, like displaying the
> UI to the client, or creating an editable version of the UI in the UI
> build tool. The modified version can then be saved back out as well.

ElementTree is a good candidate for processing xml:  
http://effbot.org/zone/element.htm
It provides a "natural" way to access elements and attributes, instead of  
writing the same handler again and again or using slow DOM functions of  
gigantic names.

> 2) Is XML fairly standard for this in Python? I recently learned about/
> was frightened by pickling. Is that worth learning? Does anyone bother
> with it?

Pickle is good for storing data that will be loaded again by (the same, or  
another) Python program. The format isn't portable to other languages, it  
isn't readable, may have security issues. But it's extensible and much  
more flexible than the other builtin alternative, marshal. You can use  
pickle as a serializer if you're aware of its limitations.

-- 
Gabriel Genellina




More information about the Python-list mailing list