I don't like f-strings (actually I was not aware what they are until I
googled them now). I also don't like the %-formatting and I prefer to use
{}-format (with or without a number or name) for all my formatting purposes.

In general, f-strings take variables which are not given to them
explicitly, which I think is wrong. The {}-format takes only variables
which are explicitly given to them.

Also when I use translations, I use the {}-format strings in the translated
strings.
אורי
u...@speedy.net


On Tue, Jul 21, 2020 at 9:55 AM Carlton Gibson <carlton.gib...@gmail.com>
wrote:

> Hi All.
>
> f-strings...
>
> There was some discussion a couple of years ago
> <https://groups.google.com/d/topic/django-developers/psUTrFUNlQE/discussion>
> about replacing all string formatting operations with f-strings.
>
> The consensus then was "No, let's not do that": %-formatting and format()
> are both great. Each has advantages
> in readability, depending on context, and there are translation and
> logging issues with f-strings.
>
> We've since not been allowing (at all) f-strings in the code. A PR comes
> in with a f-string, we remove it (or ask the author to).
>
> A few months ago this came up again
> <https://github.com/django/django/pull/12650>. We said we needed to come
> back to the mailing, because of the previous discussion,
> but the thread never started — *but* there was an amount of support for
> at least allowing f-strings. (From Claude, Jon, Nick, Paolo, Simon, ...)
>
> We have a PR again where the "Are f-strings allowed?" conversation
> <https://github.com/django/django/pull/12646#discussion_r456892548> has
> come up — so I'm posting to the list: is it time to update the policy?
>
> So let me quote Simon on #29988
> <https://code.djangoproject.com/ticket/29988#comment:8>:
>
> > I am in favor where it makes sense and has clear readability benefits. I
> don't have strong rules to provide but I've already seen this feature
> abused in the wild to compose complex formatting string which makes hard to
> differentiate placeholders from their delimiters when function calls are
> involved.
> >
> > I also share you Claude's concerns about error messages and logging
> message templates.
>
> So, paraphrasing, in favor of allowing, but it's not just true that
> f-strings are always more readable, and can't be used for strings that may
> be translated.
>
> I had the impression in ≈Feb that that kind of view would have broad
> support. 🤷‍♀️
>
> Beyond that I would like to avoid spending time updating existing uses to
> use f-strings. Sure, if we're editing, and an f-string is more reasonable,
> let's use it, but, like replacing quotes, let's not (please) spend time on
> it beyond that. (I think Jon and Nick may not agree with that from previous
> comments but...)
>
> As such I've prepared a PR suggesting a change to the Coding Style doc
> <https://github.com/django/django/pull/13214/files>, that should allow us
> to close #29988:
>
> > * String variable interpolation may use %-formatting, ``format()``, or
> >   f-strings as appropriate, with the goal of maximizing code readability.
> >   f-strings should not be used for any string that may require
> translation,
> >   including error and logging messages. Don't waste time doing unrelated
> >   refactoring of existing code to adjust the formatting method.
>
> Tweaks (as always) welcome on the PR. General discussion of the principle
> here? Shall we allow f-strings? Three formatting methods seems a lot... but
> that's what we've got, and folks are getting used to using them.
>
> Thanks for the input all!
>
> Kind Regards,
>
> Carlton
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django developers (Contributions to Django itself)" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-developers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/f7709597-7f55-4e64-9a2a-f0b62e6e1393o%40googlegroups.com
> <https://groups.google.com/d/msgid/django-developers/f7709597-7f55-4e64-9a2a-f0b62e6e1393o%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CABD5YeE_LCZ-oHXpXVGmX%3DimHPGs74GuF4qwrRyXGetvmSm-Og%40mail.gmail.com.

Reply via email to