[Python-Dev] PEP 460 reboot (original) (raw)
Guido van Rossum guido at python.org
Mon Jan 13 22:51:12 CET 2014
- Previous message: [Python-Dev] PEP 460 reboot
- Next message: [Python-Dev] PEP 460 reboot
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Terminology. Let's use the official terminology rather than making stuff up.
The docs at http://docs.python.org/3/library/string.html#formatspec use the following terminology:
Replacement field: {...}; contains field name, conversion, format spec in that order, all optional.
Field name: either a decimal integer (referring to an argument by position) or an identifier (by name), or omitted (uses the next available position).
Conversion: !r, !s, !a; these refer to repr(), str(), ascii() to the value, and then the format spec applies to the resulting string.
Format spec: colon, bunch of stuff, type; the type is a letter such as d (decimal) or s (string), and the stuff between the colon and the type is used to specify field width, alignment, sign, padding and such.
Also. {:b} means binary (i.e. numbers in base 2). I'm not sure what this leaves for interpolating bytes if we don't want to use {:s}. The docs at http://docs.python.org/3/library/stdtypes.html#printf-style-string-formatting don't show %b so it could still be used there, but it would be nicer to be consistent.
-- --Guido van Rossum (python.org/~guido)
- Previous message: [Python-Dev] PEP 460 reboot
- Next message: [Python-Dev] PEP 460 reboot
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]