> Define "fails": > > >>> "{a} {b} c" % {'a':12} > '{a} {b} c' > > That didn't fail...
Ah, my bad. I had completely overlooked that formatting was laxist when faced with unused named parameters. Then we need something smarter, like counting the number of unescaped "%" characters, the number of pairs of braces, and try first the formatting style expecting the greatest number of parameters. It can either be done cheaply in Python, or more rigourously by providing an extra API to the existing C parsing routines. This might look fragile, but we should not forget that we are talking about uses - logging, etc. - which will most of time involve very simple format strings, such that making an automatic decision is not too difficult. In the more undecideable cases, the heuristic might decide to raise an exception and require the developer to specify the formatting style explicitly (by adding e.g. style='%' or style='{}' to the method call). Regards Antoine. _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com