--
Ticket URL: <https://code.djangoproject.com/ticket/28810>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Comment (by Chris Lamb):
PR https://github.com/django/django/pull/9359
--
Ticket URL: <https://code.djangoproject.com/ticket/28810#comment:1>
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>
Comment (by Chris Lamb):
Replying to [comment:2 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 should have used a better suffix than "esque" — it's more that Python 3
code does tend to *prefer* `str.format` over `%`-style interpolation
simply as a correlation with it being more modern/newer in general. ie. if
it's "new enough" for Python 3, it's probably going to be using
newer/nicer features. It's therefore somewhat surprising to see the
reverse, hence this proposed change.
> there's a consensus against using mandating `str.format()` usage
everwhere in Django and prohibiting the `%s` syntax.
As it happens, I would be against such a total mandate and a widespread
change *within* Django, but this is more of a user-exposed thing so a
different, separate argument IMHO.
--
Ticket URL: <https://code.djangoproject.com/ticket/28810#comment:3>
* stage: Unreviewed => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/28810#comment:4>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"3af305e8b8a89f4b0e5874cd601568ab8dcd7334" 3af305e8]:
{{{
#!CommitTicketReference repository=""
revision="3af305e8b8a89f4b0e5874cd601568ab8dcd7334"
Fixed #28810 -- Replaced '%' style logging formatting with str.format()
style.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28810#comment:5>