-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Use plus sign to concatenate strings #817
Comments
I wonder if the addition of a
|
I think doing it with parentheses is better option, I was very surprised to see that black converted this: sth = {
"start_msg": "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
" Aenean sed elit venenatis, scelerisque purus ut, pretium justo."
" Donec suscipit hendrerit pretium."
} into less readable: sth = {
"start_msg": "Lorem ipsum dolor sit amet, consectetur adipiscing elit"
" Aenean sed elit venenatis, scelerisque purus ut, pretium justo."
" Donec suscipit hendrerit pretium."
} Instead of: binary = {
"start_msg": (
"Lorem ipsum dolor sit amet, consectetur adipiscing elit"
" Aenean sed elit venenatis, scelerisque purus ut, pretium justo."
" Donec suscipit hendrerit pretium."
)
} And just adding |
I strongly prefer the current behavior, which is more efficient and IMO nicer style too. I could accept adding needless parens to make this more obvious for newer pythonistas, but would be very unhappy if Black slowed down my code by adding pointless operations. (for anyone who didn't know, string + is a runtime operation whereas implicit literal concatenation happens at compile time) |
Black won't ever automatically introduce |
It seems like #620 talks about dictionary values instead of strings,
specifically the examples revolve around values with binary operators. I
agree completely that strings should be wrapped using parenthesis and
implicit concatenation but it seems like the other bug does not describe
the same issue as this one. Maybe the logic to fix these to bugs is similar
but I see value in keeping this bug open and perhaps changing the bug title.
…On Fri, Aug 16, 2019, 3:08 PM Zsolt Dollenstein ***@***.***> wrote:
Closed #817 <#817>.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#817?email_source=notifications&email_token=ABM6PXNB3QW4ODTCL7WKJYLQEZN6XA5CNFSM4HI6HGPKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOTCXS2XI#event-2561617245>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABM6PXJZCEG4T52PLK7WIWDQEZN6XANCNFSM4HI6HGPA>
.
|
I'd like to suggest that black enforces string concatenation using
+
. Why?Consider this example:
Did you see that there is a ',' missing?
I bet now you do. This is just a simple example, but I think also in other situations it could save quite some debugging time for many developers if black did this. Feel free to disagree, though, I'm open to discussion.
Related issues are #26 and #182
The text was updated successfully, but these errors were encountered: