how to format long if conditions

2011-08-27 Thread Arnaud Delobelle
Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) Here's an example taken from something I'm writing at the moment and how I've formatted it: if (isinstance(left, PyCompare) and isinstance(right,

Re: how to format long if conditions

2011-08-27 Thread Steven D'Aprano
Arnaud Delobelle wrote: Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) Here's an example taken from something I'm writing at the moment and how I've formatted it: if (isinstance(left,

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 09:08:20, Arnaud Delobelle wrote: I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to80 colums) Here's an example taken from something I'm writing at the moment and how I've formatted it: if (isinstance(left,

Re: how to format long if conditions

2011-08-27 Thread Steven D'Aprano
Hans Mulder wrote: [...] It may look ugly, but it's very clear where the condition part ends and the 'then' part begins. Immediately after the colon, surely? -- Steven -- http://mail.python.org/mailman/listinfo/python-list

Re: how to format long if conditions

2011-08-27 Thread Arnaud Delobelle
On 27 August 2011 08:24, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Arnaud Delobelle wrote: Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) Here's an example taken from something I'm

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
On 27/08/11 11:05:25, Steven D'Aprano wrote: Hans Mulder wrote: [...] It may look ugly, but it's very clear where the condition part ends and the 'then' part begins. Immediately after the colon, surely? On the next line, actually :-) The point is, that this layout makes it very clear that

Re: how to format long if conditions

2011-08-27 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: I believe that PEP 8 now Specifically the “Indentation” section contains:: When using a hanging indent the following considerations should be applied; there should be no arguments on the first line and further indentation

Re: how to format long if conditions

2011-08-27 Thread Colin J. Williams
On 27-Aug-11 03:50 AM, Hans Mulder wrote: On 27/08/11 09:08:20, Arnaud Delobelle wrote: I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to80 colums) Here's an example taken from something I'm writing at the moment and how I've

Re: how to format long if conditions

2011-08-27 Thread Hans Mulder
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

Re: how to format long if conditions

2011-08-27 Thread Roy Smith
In article mailman.457.1314428909.27778.python-l...@python.org, Arnaud Delobelle arno...@gmail.com wrote: Hi all, I'm wondering what advice you have about formatting if statements with long conditions (I always format my code to 80 colums) [...] if (isinstance(left, PyCompare) and

Re: how to format long if conditions

2011-08-27 Thread Colin J. Williams
On 27-Aug-11 11:53 AM, Hans Mulder wrote: 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 =