You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One more thing, unpacking is a good thing and should be allowed: a, b = some_tuple()
The thing about this example is that [], [] does not look like a real tuple. But, for example: x, y = (1, 2) looks pretty readable to me.
So, we need to find a balance between an obviously good idea - one assignment per line - and some real-world usages, when this rule is not applicable.
One more thing, unpacking is a good thing and should be allowed: a, b = some_tuple()
Exactly 👍🏿
But, for example: x, y = (1, 2) looks pretty readable to me.
I don't think it will drop readability if it is on separate lines. Moreover, now I work on a codebase that has plenty of it and I always miss where the initialization of the second variable (y in your example) happens. So, I don't have cases in mind when one-line initialization is useful.
Ok, there is one case: swapping variables (x, y = y, x). However, I can't recall any case when I actually used it. Non-recursive GCD, maybe.
I disagree that x, y = (1, 2) is particularly good style. I vouch for forbidding assigning more than 2 variables on one line. On the rare occasion that someone needs to implement GCD they can use noqa.
Rule request
Thesis
Reasoning
Decrease unnecessary code line complexity.
The text was updated successfully, but these errors were encountered: