Addendum to @ sr2222's answer. Typically, you only need these parentheses if you want to continue recording on the next line. For example, you can use parentheses to declare a line on two lines in two ways:
In [1]: s1 = 'abc' \ ...: 'def' In [2]: s1 Out[2]: 'abcdef' In [3]: s2 = ('abc' ...: 'def') In [4]: s2 Out[4]: 'abcdef'
The same applies to if-statement, for example. Use parentheses to split the expression into multiple lines:
In [6]: if 1 in \ ...: [1,2,3]: ...: pass In [7]: if (1 in ...: [1,2,3]): ...: pass
Both versions are the same in functionality. But using parentheses instead of backslash is the best style. This is the same with your import operations. If the whole expression matches one line, you don't need parentheses at all.
source share