Re: template strings for matching?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Joe Strout

    Re: template strings for matching?

    On Oct 9, 2008, at 7:05 AM, skip@pobox.com wrote:
    Tinohttp://docs.python.org/library/stdty...ing-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


Working...