On Tue, November 3, 2009 09:43, Binger David wrote: > Yes, we need to play nice with format(). > I think this will require adding a method to the xml class. > The first thing to do is write the method in python. Thanks for the nudge in the right direction. > Would this work? > > def format(self, *args, **kwargs): > quoted_args = tuple(_quote_wrap(arg for arg in args)) > quoted_kwargs = _xml_quote_wrapper(x) > return xml(unicode_str.format(self, *quoted_args, > **quoted_kwargs)) Nope, for reason of typos as well as something underlying which I was not quite able to put my finger on. I suppose lurking about, possibly in the C code for string, we'll find the answer. Here's the symptom - wrapping kwargs with _xml_quote_wrapper causes .format() to fail:: File "/usr/local/lib/python2.6/site-packages/qpy-1.8-py2.6.egg/qpy/quoted.py", line 128, in format return xml(unicode_str.format(self, *quoted_args, **quoted_kwargs)) TypeError: method_descriptor object argument after ** must be a mapping, not _xml_quote_wrapper My search for the source of the TypeError has so far turned up nothing. Since I couldn't find what was complaining to see if the wrapper class could be modified to accommodate the complainer, here using a reconstructed kwargs is a lightly tested working .format() method for the xml() class: def format(self, *args, **kwargs): quoted_args = tuple(_quote_wrap(arg) for arg in args) quoted_kwargs = dict([(k, _quote_wrap(v)) for k, v in kwargs.iteritems()]) return xml(unicode_str.format(self, *quoted_args, **quoted_kwargs))