On Oct 9, 2008, at 7:05 AM, [EMAIL PROTECTED] wrote:

   Tino> 
http://docs.python.org/library/stdtypes.html#string-formatting-operations

That shows how to use the template formatting as it currently exists. To my knowledge there is no support for the inverse operation, which is what Joe asked about. Given a string and a format string assign the elements of the string which correspond to the template elements to key/value pairs in a
dictionary.

Right.

Well, what do y'all think? It wouldn't be too hard to write this for myself, but it seems like the sort of thing Python ought to have built in. Right on the Template class, so it doesn't add anything new to the global namespace; it just makes this class more useful.

I took a look at PEP 3101, which is more of a high-powered string formatter (as the title says, Advanced String Formatting), and will be considerably more intimidating for a beginner than Template. So, even if that goes through, perhaps Template will stick around, and being able to use it in both directions could be quite handy.

Oh boy!  Could this be my very first PEP?  :)

Thanks for any opinions,
- Joe


--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to