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():
       '<span style="font-size:3em;">{0}</span>'.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.

   '<span style="font-size:3em;">%s</span>' % 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
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/qp

_______________________________________________
QP mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/qp

Reply via email to