Re: Python string formatting

2018-11-01 Thread Tim Graham
I fail to see a problem with %. It's the primary format used throughout Django. The Django tutorial assumes some knowledge of Python, so I'd expect most newcomers would be familiar with both string formatting syntaxes. Maybe I'm just an old curmudgeon, but I find the tutorial examples more read

Re: Python string formatting

2018-11-01 Thread mandark . dev
Thanks everybody for your answers. # Why not wait and jump directly to f-strings? I like f-strings a lot too, but they does not work with i18n at the moment. (To work with i18n we'll need something like PEP 501 [1], currently deferred). # Diff would be large :( Translation would be to be rewr

Re: Python string formatting

2018-11-01 Thread Claude Paroz
Le jeudi 1 novembre 2018 15:37:21 UTC+1, charettes a écrit : > > FWIW it looks like gettext support issues were addressed a while ago[0] > For the .format() syntax, yes. For f-strings, I'm not sure they can be internationalized at all. PEP 498 has not a word about it. Claude -- You received th

Re: Python string formatting

2018-11-01 Thread charettes
FWIW it looks like gettext support issues were addressed a while ago[0] The main issue standing with existing translations is that they'll need to be regenerated[1] which would require a non-trivial amount of coordination between translation teams I assume. Simon [0] https://bugs.debian.org/cgi

Re: Python string formatting

2018-11-01 Thread Ian Foote
I think {} formatting has some minor readability benefits. The symmetry of the braces makes it easier (imo) to see at a glance what is going to be interpolated. With % formatting the alphabetical characters can be obscured by other text in the string, especially if there's not a space after it. I'v

Re: Python string formatting

2018-10-31 Thread Tim Graham
Another discussion is https://groups.google.com/d/topic/django-developers/J9CfWIgrgbY/discussion - % vs {} string formatting for public APIs I haven't seen any practical benefits to prefer format() over %s. I find the latter less verbose. I'm not certain what this argument is (things like htt

Re: Python string formatting

2018-10-31 Thread Tom Forbes
In my experience f strings are vastly more expressive than .format, but not much better than % based formatting. If we can make this change after we drop 3.5 I think it will be a lot easier. On Wed, 31 Oct 2018, 21:09 Adrian Turjak There was a push to deprecated % formatting but too many people

Re: Python string formatting

2018-10-31 Thread Adrian Turjak
There was a push to deprecated % formatting but too many people complained and that never happened.While .format and g-strings are superior, % is here to stay for the foreseeable future. Too many people still use it (including myself sometimes).On 1 Nov. 2018 08:14, Carlton Gibson wrote:We had a b

Re: Python string formatting

2018-10-31 Thread Carlton Gibson
Sorry, I typed that up and forgot to paste the link 🙄 On Wednesday, 31 October 2018 20:14:14 UTC+1, Carlton Gibson wrote: > > We had a bit of a discussion of this on > https://code.djangoproject.com/ticket/29623 -- You received this message because you are subscribed to the Google Groups "Dj

Re: Python string formatting

2018-10-31 Thread Carlton Gibson
We had a bit of a discussion of this on Python 2 docs have got this re format(): > This method of string formatting is the new standard in Python 3, and should be preferred to the % formatting described in String Formatting Operations in new code. ​https://docs.python.org/2/library/stdtypes

Re: Python string formatting

2018-10-31 Thread charettes
I don't have a strong opinion on whether or not we should make the switch but if the consensus is too move forward with this I'd suggest we wait until Django master's branch only supports Python 3.6+. That would allow us to switch directly to f-strings and avoid doubling the already large diff

Python string formatting

2018-10-31 Thread mandark . dev
Hi, Long story short, I discovered [1] there is no concensus [2] on which formatting to use in the Django tutorial. An argument for % (or against the format method) was https://savannah.gnu.org/bugs/?30854 but it has been fixed 5 years ago, its stays an argument against f-strings. It seemed o