how to format long if conditions
Hans Mulder
hansmu at xs4all.nl
Sat Aug 27 11:53:48 EDT 2011
On 27/08/11 17:16:51, Colin J. Williams wrote:
> What about:
> cond= isinstance(left, PyCompare)
> and isinstance(right, PyCompare)
> and left.complist[-1] is right.complist[0]
> py_and= PyCompare(left.complist + right.complist[1:])if cond
> else: py_and = PyBooleanAnd(left, right)
> Colin W.
That's a syntax error. You need to add parenthesis.
How about:
cond = (
isinstance(left, PyCompare)
and isinstance(right, PyCompare)
and left.complist[-1] is right.complist[0]
}
py_and = (
PyCompare(left.complist + right.complist[1:])
if cond
else PyBooleanAnd(left, right)
)
-- HansM
More information about the Python-list
mailing list