[Python-ideas] Where/how to propose an addition to a standard module?

Terry Reedy tjreedy at udel.edu
Mon Oct 13 22:43:17 CEST 2008

Leif Walsh wrote:
> On Mon, Oct 13, 2008 at 12:51 PM, Steven Bethard
> <steven.bethard at gmail.com> wrote:
>> If I were proposing something like this, I'd be using the new
>> formatting syntax that's supposed to become the standard in Python
>> 3.0:
>>  http://docs.python.org/dev/3.0/library/string.html#format-string-syntax
>> That would mean something like::
>>  '{name} was born in {country}'
> I agree, but it seems something more is needed here.  I would like to
> be able to parse something that isn't separated by whitespace, and I'd
> like to be able to tell Python to turn it into an int if I need to.
> We could keep a similar syntax to the 3.0 formatting syntax, and just
> change the semantics:

Given that I have never used the Template class and am using 3.0 
str.format, that I believe the former was the bridge that led to the 
latter, and am not enamored of writing REs, I think adding str.match 
would be a great idea.  To the extent possible,
   s  == form.format(form.match(s)) and
   args == form.match(form.format(args).
Note that args can either be a sequence or mapping.

This might encourage more people to switch faster from % to .format. 
Given that Guido wants this to happen, he might look favorably

> ""First, thou shalt count to {n!i}" (or {n!d}) could parse an integer
> out of the string, and "{!x:[0-9A-Fa-f]*}" + (":{!x:[0-9A-Fa-f]*}" *
> 7) could be used to parse MAC addresses into a list of 8 hex values.
> I could easily see this getting way too complex,

Let us not make the perfect be the enemy of the possible.

> so maybe you all should just ignore me.


Terry Jan Reedy


More information about the Python-ideas mailing list