#28810: Use the Python 3-esque str.format logging formatting style over '%'
-------------------------------------+-------------------------------------
Reporter: Chris Lamb | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Core (Other) | Version: 1.11
Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Old description:
> We currently use the ``%(foo)s`` style in Django and in docs. This
> "smells" quite Python 2.x when there is a ``str.format`` variety that
> uses, eg. ``{foo}``.
New description:
We currently use the `%(foo)s` style in Django and in docs. This "smells"
quite Python 2.x when there is a `str.format` variety that uses, eg.
`{foo}`.
--
Comment (by Tim Graham):
I'm not sure why you say "Python 3-esque str.format" in the description.
`str.format()` was added in Python 2.6. I see that logging support for
that style (by using `style='{'`) was added in Python 3.2.
I'm not opposed to the change, as it seems like a slight readability
enhancement, although generally I think there's a consensus against using
mandating `str.format()` usage everwhere in Django and prohibiting the
`%s` syntax. I think there was a ticket but I can't find it at the moment.
My only concern with the proposal is whether it could break backwards
compatibility. I see an update to `ServerFormatter.uses_server_time()` was
required. I'm not sure if it's likely that user code may make similar
assumptions about the format string.
--
Ticket URL: <https://code.djangoproject.com/ticket/28810#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/063.3e120bda6f1684a49c432e1aed2af846%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.