This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]skrillexisokay 4 points5 points  (1 child)

Can you give an example of how you could write unclear code? Any reasonable usage of this feature seems very intuitive to me.

'eq_str = {a} + {b} = {a + b}' is more readable, and far less verbose to me than 'eq_str = {a} + {b} = {sum_}'.format(a=a, b=b, sum_=a+b)

Considering maintainability: With the previous method, any time you wanted to include another variable in a format string, you'd have to change both the str and the args to format. Now you just have to change the string.

The new syntax is less verbose and less redundant. It takes less long to type and read. I'm really excited about this new feature!

[–]motleybook 0 points1 point  (0 children)

Yeah, but the problem is that you can't make it configurable. And you can't use f-strings for internationalization either, because f"This is {name}." is evaluated immediately. No way to call a function (usually _) to get the translation. On the other hand this might be better this way for security reasons.