[Python-Dev] transitioning from % to {} formatting

Vinay Sajip vinay_sajip at yahoo.co.uk
Sat Oct 3 19:38:36 CEST 2009


Paul Moore <p.f.moore <at> gmail.com> writes:

> Still tangential, but it seems to me that this discussion has exposed
> a couple of areas where the logging interface is less than ideal:
> 
> - The introspection of the format string to delay computing certain
> items (Eric's suggestion may be an improvement here).

Yes, but that's an implementation detail and not part of the logging interface.
It can be changed without any particular additional impact on user code - when
I say "additional" I mean apart from the need to change the format strings to
{} format, which they would have to do anyway at some point.

> - The "call str() on any non-string object to get a format string" API
> (which precludes string subclasses).

It doesn't preclude string subclasses: it just calls str() on an arbitrary
message object to get the string representation for that object. The return
value is used to interpolate into the formatted output, and that's all. So
I don't understand what's being precluded and how - please elaborate.

Thanks & regards,

Vinay Sajip



More information about the Python-Dev mailing list