Related questions
Styling multi-line conditions in 'if' statements?
Sometimes I break long conditions in ifs onto several lines. The most obvious way to do this is:
if (cond1 == 'val1' and cond2 == 'val2' and
cond3 == 'val3' and cond4 == 'val4'):
do_something
Isn't very very appealing …
How do I return multiple values from a function?
The canonical way to return multiple values in languages that support it is often tupling.
Option: Using a tuple
Consider this trivial example:
def f(x):
y0 = x + 1
y1 = x * 3
y2 = y0 ** y3
return (y0, y1, y2)
However, this quickly …
Python `if x is not None` or `if not x is None`?
I've always thought of the if not x is None version to be more clear, but Google's style guide and PEP-8 both use if x is not None. Is there any minor performance difference (I'm assuming not), and is there …