-
-
Notifications
You must be signed in to change notification settings - Fork 389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Forbid using f
strings
#32
Comments
vs
The only reason not to use them all the time is backwards compatibility. UPD: Although it would be nice to have a way of enforcing The Only Way of formatting strings on a project. |
I guess, @sobolevn really wants just linters for f-strings code and some heuristic to forbid doing complex things inside f-strings. |
We can actually forbid the usage in the form of |
def some(self):
return '{0} with {1}'.format(name, item) But, for me being shorter is not a valid argument. What matters is:
ReadabilityMy old habits put But, what really makes a difference is that we can not put logics inside >>> f'{random.randint(1, 12)}'
'3' That is so wrong, that I can not allow this. PerformanceYes, Consistency
I don't see any use-cases of |
I'm starting to agree with you. Here's another one: if you have a long multiline string that you need to format, you probably better off putting the string in another file and using a template engine. The |
No. |
Hey, folks 👋 about Readability What's the big difference between this two lines? |
No, the template part is pure: template = 'v={v}'
string = template.format(v=...) |
well, i can, but not forced to. |
Yes 👍 |
Even though this is closed, I want to reply to this: |
No, we also try to forbid all other things 🙂 |
O.K. then. |
I don't see any reasons why we should use them.
Let's use
.format()
instead.P.S. For a reason we can not forbid
%
usage: gforcada/flake8-pep3101#23The text was updated successfully, but these errors were encountered: