[I18n-sig] XML and codecs

M.-A. Lemburg mal@lemburg.com
Thu, 07 Jun 2001 10:36:37 +0200

"Martin v. Loewis" wrote:
> > The codec will place the work done so far into the third
> > tuple argument and the position which caused the failure
> > into the second. reason can be used to provide additional
> > information to the caller.
> How does that work with writelines()? In this case, the caller does
> not have the string which the position refers to.

In that case you'd either 

a) have to subclass the StreamWriter
and provide the necessary logic in the .writelines() method
(using the .write() method to do the actual work) or 

b) forget about .writelines() and move the for-loop directly into
your application or

c) use u"".join(datalines) and .write().

Not really all that difficult.

Marc-Andre Lemburg
CEO eGenix.com Software GmbH
Company & Consulting:                           http://www.egenix.com/
Python Software:                        http://www.lemburg.com/python/