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-03
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.

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



On Nov 2, 2009, at 3:14 PM, Michael Watkins wrote:

> Is it possible to extend the QPY compiler to recognize:
>
> foo_var = '& quote only these two ampersands &'
>
>    def test:xml():
>        '{0}'.format(foo_var)
>
> Currently the entire string object result ends up being quoted,
> where as
> the old string parameter replacement approach quotes only objects not
> marked quote-no-more.
>
>    '%s' % foo_var
>
> I haven't started using the new .format() method in earnest but may be
> more interested in it if/when the changes to placeholders in 3.1 which
> allow implied positional arguements are back ported to > 2.6.
>
> http://docs.python.org/3.1/library/string.html#formatstrings
>
> _______________________________________________
> QP mailing list
> QP@mems-exchange.org
> http://mail.mems-exchange.org/mailman/listinfo/qp

reply