
July 21, 2015
4:43 a.m.
Eric V. Smith wrote:
Right. But why re-implement that, instead of making it: '{[n]}'.format(a)?
Consider also the case of custom formatters. I've got one that overloads format_field, adds a units specifier in the format, which then uses our model units conversion and writes values in the current user-units of the system: x = body.x_coord # A "Double()" object with units of length. print(f'{x:length:.3f}') # Uses the "length" string to perform a units conversion much as "!r" would invoke "repr()". I think your proposal above handles my use case the most cleanly. Another Eric