Skip to content

Ruff auto add parentheses to a long line of code #13582

Answered by Ravencentric
bavo96 asked this question in Q&A
Discussion options

You must be logged in to vote
this_is_a_very_long_variable = 1
this_is_another_ver_long_variable = 2
this_is_the_last_long_variable = 3

message = (
    this_is_a_very_long_variable
    + this_is_another_ver_long_variable
    + this_is_the_last_long_variable
)

Have you tried running it? If you do print(message) you'll see that it's still a number. And if you do message[0] it'll raise an error about how int is not subscriptable.

>>> a = (
... 1
... + 2
... + 3
... )
>>> b = (1 + 2 + 3)
>>> c = 1, 2, 3
>>> type(a)
<class 'int'>
>>> type(b)
<class 'int'>
>>> type(c)
<class 'tuple'>
>>> 

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@bavo96
Comment options

@Ravencentric
Comment options

Answer selected by bavo96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants