[Python-Dev] PEP 3101: Advanced String Formatting (original) (raw)

Aahz aahz at pythoncraft.com
Sun Apr 30 15:16:56 CEST 2006


First of all, I recommend that you post this to comp.lang.python. This is the kind of PEP where wide community involvement is essential to success; be prepared for massive revision. (My point about massive revision would be true regardless of how much consensus has been reached on python-dev -- PEPs often change radically once they're thrown into the wild.)

On Sat, Apr 29, 2006, Talin wrote:

Braces can be escaped using a backslash: "My name is {0} :-{}".format('Fred')

You should include somewhere reasoning for using "{" and "}" instead of "{{" and "}}".

Simple names are either names or numbers. If numbers, they must be valid decimal numbers; if names, they must be valid Python identifiers. A number is used to identify a positional argument, while a name is used to identify a keyword argument.

s/decimal numbers/decimal integers/ (or possibly "base-10 integers" for absolute clarity)

The parameters to the cformat function are:

-- The format string (or unicode; the same function handles both.) -- A field format hook (see below) -- A tuple containing the positional arguments -- A dict containing the keyword arguments The cformat function will parse all of the fields in the format string, and return a new string (or unicode) with all of the fields replaced with their formatted values. For each field, the cformat function will attempt to call the field format hook with the following arguments: fieldhook(value, conversion, buffer)

You need to explain further what a field format hook is and how one specifies it.

Aahz (aahz at pythoncraft.com) <*> http://www.pythoncraft.com/

"Argue for your limitations, and sure enough they're yours." --Richard Bach



More information about the Python-Dev mailing list