Lately have seen imports like this
from module import (function, another_function,
another_function)
Seemingly this has been done to be able to stretch the import
statement over more than one line. In cases like this I usually just import like so
from module import function, another_function, \
another_function
What exactly are the parentheses doing in this case and are they considered to be bad practice?
As PEP 8 states:
The preferred way of wrapping long lines is by using Python's implied line continuation inside parentheses, brackets and braces. Long lines can be broken over multiple lines by wrapping expressions in parentheses. These should be used in preference to using a backslash for line continuation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With