Re: if, continuation and indentation

2010-06-09 Thread Jean-Michel Pichavant
Pete Forman wrote: HH writes: > I have a question about best practices when it comes to line > wrapping/ continuation and indentation, specifically in the case of > an if statement. There are several good suggestions for formatting but no-one has mentioned rewriting the code. Use a boolean

Re: if, continuation and indentation

2010-06-09 Thread Pete Forman
HH writes: > I have a question about best practices when it comes to line > wrapping/ continuation and indentation, specifically in the case of > an if statement. There are several good suggestions for formatting but no-one has mentioned rewriting the code. Use a boolean variable to hold the

Re: if, continuation and indentation

2010-06-07 Thread Greg Couch
On May 27, 5:22 am, HH wrote: > I have a question about best practices when it comes to line wrapping/ > continuation and indentation, specifically in the case of an if > statement. > > When I write an if statement with many conditions, I prefer to use a > parenthesis around the whole block and ge

Re: if, continuation and indentation

2010-06-04 Thread Aahz
In article , Tim Chase wrote: > >While it's not PEP material, I tend to use the coding standards I >learned working for Computer Sciences Corporation (10 yrs ago, so >things may have changed) that mandated 2 levels of indentation >for continued lines, turning the above into > > if (width ==

Re: if, continuation and indentation

2010-06-04 Thread Giacomo Boffi
HH writes: > if (width == 0 and > height == 0 and > color == 'red' and > emphasis == 'strong' or > highlight > 100): > raise ValueError("sorry, you lose") if (width == 0 and height == 0 and color == 'red' and emphasis == 'strong' or

Re: if, continuation and indentation

2010-05-31 Thread Colin J. Williams
On 31-May-10 17:15 PM, Lie Ryan wrote: On 05/31/10 05:10, Colin J. Williams wrote: On 30-May-10 01:50 AM, Nathan Rice wrote: On 27-May-10 08:48 AM, Xavier Ho wrote: > On 27 May 2010 22:22, HHmailto:henri...@gmail.com>>

Re: if, continuation and indentation

2010-05-31 Thread Lie Ryan
On 05/31/10 05:10, Colin J. Williams wrote: > On 30-May-10 01:50 AM, Nathan Rice wrote: >> On 27-May-10 08:48 AM, Xavier Ho wrote: >> > On 27 May 2010 22:22, HH> > > >

Re: if, continuation and indentation

2010-05-30 Thread Colin J. Williams
On 30-May-10 01:50 AM, Nathan Rice wrote: I prefer to just break such things into multiple lines. You're doing that already anyhow, it's not much of a speed hit, and it makes exactly what you're testing explicit. If I break a statement onto multiple lines I only use parenthesis, and that is as

Re: if, continuation and indentation

2010-05-29 Thread Nathan Rice
I prefer to just break such things into multiple lines. You're doing that already anyhow, it's not much of a speed hit, and it makes exactly what you're testing explicit. If I break a statement onto multiple lines I only use parenthesis, and that is as a last resort. In my opinion there's almost

Re: if, continuation and indentation

2010-05-29 Thread Mark Lawrence
On 30/05/2010 01:23, john wrote: On May 28, 10:37 am, "Colin J. Williams" wrote: On 28-May-10 05:54 AM, Jonathan Hartley wrote: On May 27, 1:57 pm, Jean-Michel Pichavant wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, spec

Re: if, continuation and indentation

2010-05-29 Thread john
On May 28, 10:37 am, "Colin J. Williams" wrote: > On 28-May-10 05:54 AM, Jonathan Hartley wrote: > > > On May 27, 1:57 pm, Jean-Michel Pichavant > > wrote: > >> HH wrote: > >>> I have a question about best practices when it comes to line wrapping/ > >>> continuation and indentation, specifically i

Re: if, continuation and indentation

2010-05-28 Thread Colin J. Williams
On 28-May-10 05:54 AM, Jonathan Hartley wrote: On May 27, 1:57 pm, Jean-Michel Pichavant wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many c

Re: if, continuation and indentation

2010-05-28 Thread Jonathan Hartley
On 28/05/2010 11:34, Jean-Michel Pichavant wrote: Jonathan Hartley wrote: On May 27, 1:57 pm, Jean-Michel Pichavant wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I w

Re: if, continuation and indentation

2010-05-28 Thread Jean-Michel Pichavant
Jonathan Hartley wrote: On May 27, 1:57 pm, Jean-Michel Pichavant wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions,

Re: if, continuation and indentation

2010-05-28 Thread Jonathan Hartley
On May 27, 1:57 pm, Jean-Michel Pichavant wrote: > HH wrote: > > I have a question about best practices when it comes to line wrapping/ > > continuation and indentation, specifically in the case of an if > > statement. > > > When I write an if statement with many conditions, I prefer to use a > >

Re: if, continuation and indentation

2010-05-27 Thread HH
On May 27, 11:37 am, Alain Ketterlin wrote: > HH writes: > >     if (width == 0 and > >         height == 0 and > >         color == 'red' and > >         emphasis == 'strong' or > >         highlight > 100): > >         raise ValueError("sorry, you lose") > > I prefer to see the "and" at the beg

Re: if, continuation and indentation

2010-05-27 Thread Jean-Michel Pichavant
MRAB wrote: HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit co

Re: if, continuation and indentation

2010-05-27 Thread Alain Ketterlin
HH writes: > if (width == 0 and > height == 0 and > color == 'red' and > emphasis == 'strong' or > highlight > 100): > raise ValueError("sorry, you lose") I prefer to see the "and" at the beginning of continuation lines, and usually group related items

Re: if, continuation and indentation

2010-05-27 Thread Harald Luessen
On Thu, 27 May 2010 HH wrote: >I have a question about best practices when it comes to line wrapping/ >continuation and indentation, specifically in the case of an if >statement. > >if (width == 0 and >height == 0 and >color == 'red' and >emphasis == 'strong' or >

Re: if, continuation and indentation

2010-05-27 Thread MRAB
HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, r

Re: if, continuation and indentation

2010-05-27 Thread Tim Chase
On 05/27/2010 07:22 AM, HH wrote: When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, rather than ending each line with an escape character. Thus, using the example from the style guide (http://www.python.org/

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 23:26, Xavier Ho wrote: > Oh, one minor optimisation. You can put the last condition first > I take that back. You really can't, without using more parans or ifs. Apologies. -Xav -- http://mail.python.org/mailman/listinfo/python-list

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:57, Jean-Michel Pichavant wrote: > One possible solution >> >> if ( >> width == 0 and >> height == 0 and >> color == 'red' and >> emphasis == 'strong' or >> highlight > 100 >> ): >> raise ValueError("sorry, you lose

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:57, Jean-Michel Pichavant wrote: > One possible solution > > if ( > width == 0 and > height == 0 and > color == 'red' and > emphasis == 'strong' or > highlight > 100 > ): > raise ValueError("sorry, you lose") > > But

Re: if, continuation and indentation

2010-05-27 Thread Jean-Michel Pichavant
HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, r

Re: if, continuation and indentation

2010-05-27 Thread Martin P. Hellwig
On 05/27/10 13:22, HH wrote: I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the impli

Re: if, continuation and indentation

2010-05-27 Thread Xavier Ho
On 27 May 2010 22:22, HH wrote: >if (width == 0 and >height == 0 and >color == 'red' and >emphasis == 'strong' or >highlight > 100): >raise ValueError("sorry, you lose") > I've gotta say - I've bumped into this problem before, and I'm sure many other h

if, continuation and indentation

2010-05-27 Thread HH
I have a question about best practices when it comes to line wrapping/ continuation and indentation, specifically in the case of an if statement. When I write an if statement with many conditions, I prefer to use a parenthesis around the whole block and get the implicit continuation, rather than e