How to deal with long lines in Python?

1.2k Views Asked by At

I have this really long line in Python, due to several reasons, that I'm trying to break up.

long_variable_name = somelongmodule.SomeLongClassName.VeryLongFunctionName(...

I know the recommended way to break up a line is at the parentheses, but I haven't even gotten there yet. What might be some solution to this problem?

1

There are 1 best solutions below

0
Stefan Pochmann On BEST ANSWER

A very long function name is probably unproblematic to import directly:

from somelongmodule.SomeLongClassName import VeryLongFunctionName

long_variable_name = VeryLongFunctionName(...

And/or break the line after the variable name:

long_variable_name = \
    somelongmodule.SomeLongClassName.VeryLongFunctionName(...

Also, you might want to try not having very long names in the first place.