What meaning of this ""hello %s you are %s years old" % x"
Albert-Jan Roskam
fomcl at yahoo.com
Mon Jul 28 03:41:35 EDT 2014
<snip>
> That's not tuple%tuple, but rather string%tuple. And string%tuple is
> the older method of formatting an output string from a template and a
> tuple of values. See
> https://docs.python.org/2/library/stdtypes.html#string-formatting for
> details.
>
> However, if you are just learning Python, you should probably use the
> *newer* formatting operations. See
> https://docs.python.org/3.3/library/string.html#formatspec for details
> of that.
Do you know what was the reason/consideration to switch to a new formatting operation? Ability to have custom formatters with an own __format__ method?
Regards,
Albert-Jan
More information about the Python-list
mailing list