durusmail: qp: QPY support for new string format method?
QPY support for new string format method?
2009-11-02
2009-11-03
2009-11-03
2009-11-04
2009-11-04
QPY support for new string format method?
Binger David
2009-11-04
On Nov 3, 2009, at 2:37 PM, Michael Watkins wrote:

> My search for the source of the TypeError has so far turned up
> nothing.

We could fix this, I think, but I prefer the more direct approach
that you suggest below, if it works.  The wrappers are there to support
"lazy" quoting, so that % arguments like locals() would work without
quoting everything in advance.  For the format() function, I think we
could get by with simply quoting the arguments that are provided.

Let me know if you discover any problem with your python
implementation.  If I get time, I'll work on a C version and we
can include the new format() in the next QPY release.

Thanks for thinking about this.

>
> 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))

reply