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

Paul Moore p.f.moore at gmail.com
Fri Oct 2 15:20:28 CEST 2009

2009/10/1 Eric Smith <eric at trueblade.com>:
> It's tangential, but in the str.format case you don't want to check for just
> '{asctime}', because you might want '{asctime:%Y-%m-%d}', for example.
> But there are ways to delay computing the time until you're sure it's
> actually being used in the format string, without parsing the format string.
> Now that I think of it, the same technique could be used with %-formatting:

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).
- The "call str() on any non-string object to get a format string" API
(which precludes string subclasses).

I suspect other APIs will exist with similar issues once the whole
question of supporting multiple format syntaxes gets wider


More information about the Python-Dev mailing list