ANN: XML builder for Python
Walter Dörwald
walter at livinglogic.de
Thu Jul 3 17:48:27 EDT 2008
Jonas Galvez wrote:
> Walter Dörwald wrote:
>> XIST has been using with blocks since version 3.0.
>> [...]
>> with xsc.Frag() as node:
>> +xml.XML()
>> +html.DocTypeXHTML10transitional()
>> with html.html():
>> [...]
>
> Sweet! I don't like having to use the unary operator tho, I wanted
> something as simple as possible, so I wouldn't even have to assign a
> variable on the with block ("as something").
You only have to assign the node a name in the outermost with block so
that you can use the node object afterwards. But of course you can
always implement the outermost __enter__/__exit__ in such a way, that
the node gets written to an outputstream immediately.
> I plan to add some
> validation and error checking, but for generating feeds for my Atom
> store it's reasonably fast and lean (just over 50 lines of code).
Servus,
Walter
More information about the Python-list
mailing list