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

Leif Walsh leif.walsh at gmail.com
Mon Oct 13 21:19:59 CEST 2008


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:

""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, so maybe you all
should just ignore me.

-- 
Cheers,
Leif



More information about the Python-ideas mailing list