Re: Idioms and Anti-Idioms Question

2009-07-03 Thread Lawrence D'Oliveiro
In message , J. Cliff Dyer wrote: > On Wed, 2009-07-01 at 17:19 +1200, Lawrence D'Oliveiro wrote: >> >> In message , J. >> Cliff Dyer wrote: >> >> > If the lines got separated, a leading + could disappear into its line >> > without any errors showing up. A trailing + would raise a syntax >> > e

Re: Idioms and Anti-Idioms Question

2009-07-02 Thread J. Cliff Dyer
On Wed, 2009-07-01 at 17:19 +1200, Lawrence D'Oliveiro wrote: > In message , J. Cliff > Dyer wrote: > > > If the lines got separated, a leading + could disappear into its line > > without any errors showing up. A trailing + would raise a syntax error. > > Unless, of course, it was moved onto th

Re: Idioms and Anti-Idioms Question

2009-07-01 Thread Lawrence D'Oliveiro
In message , J. Cliff Dyer wrote: > If the lines got separated, a leading + could disappear into its line > without any errors showing up. A trailing + would raise a syntax error. Unless, of course, it was moved onto the previous line as part of whatever caused the separation of the lines. How

Re: Idioms and Anti-Idioms Question

2009-06-23 Thread Lie Ryan
Peter Billam wrote: > On 2009-06-22, Lie Ryan wrote: >> Ben Charrow wrote: >>> value = foo.bar()['first'][0]*baz.quux(1, 2)[5:9] \ >>> + calculate_number(10, 20)*forbulate(500, 360) >>> What is subtly wrong about this piece of code? I can't see any bugs and >>> can't think of subtle gotch

Re: Idioms and Anti-Idioms Question

2009-06-23 Thread J. Cliff Dyer
On Mon, 2009-06-22 at 22:52 +, Peter Billam wrote: > I wonder on what grounds PEP8 > says "The preferred place to break around a binary operator is > *after* the operator" ? > Perhaps it's just the "continutation marker" rationale? > > Regards, Peter > > -- > Peter Billam www.pjb.com

Re: Idioms and Anti-Idioms Question

2009-06-23 Thread Carl Banks
On Jun 21, 9:14 pm, Ben Charrow wrote: > I have a question about the "Using Backslash to Continue Statements" in the > howto "Idioms and Anti-Idioms in Python" > (http://docs.python.org/howto/doanddont.html#using-backslash-to-contin...) > > It says: > > "...if the code was: > > value = foo.bar()['

Re: Idioms and Anti-Idioms Question

2009-06-23 Thread Gabriel Genellina
En Mon, 22 Jun 2009 20:34:40 -0300, Miles Kaufmann escribió: On Jun 22, 2009, at 12:14 AM, Ben Charrow wrote: What is subtly wrong about this piece of code? I can't see any bugs and can't think of subtle gotchas (e.g. the '\' is removed or the lines become separated, because in both cases

Re: Idioms and Anti-Idioms Question

2009-06-23 Thread Lawrence D'Oliveiro
In message , Peter Billam wrote: > Damian Conway, in Perl Best Practices, puts forward a clear argument > for breaking *before* the operator: Except in JavaScript, where you have no choice. -- http://mail.python.org/mailman/listinfo/python-list

Re: Idioms and Anti-Idioms Question

2009-06-22 Thread Miles Kaufmann
On Jun 22, 2009, at 12:14 AM, Ben Charrow wrote: What is subtly wrong about this piece of code? I can't see any bugs and can't think of subtle gotchas (e.g. the '\' is removed or the lines become separated, because in both cases an IndentationError would be raised). Perhaps, along with o

Re: Idioms and Anti-Idioms Question

2009-06-22 Thread Peter Billam
On 2009-06-22, Lie Ryan wrote: > Ben Charrow wrote: >> value = foo.bar()['first'][0]*baz.quux(1, 2)[5:9] \ >> + calculate_number(10, 20)*forbulate(500, 360) >> What is subtly wrong about this piece of code? I can't see any bugs and >> can't think of subtle gotchas (e.g. the '\' is removed

Re: Idioms and Anti-Idioms Question

2009-06-22 Thread Lawrence D'Oliveiro
In message , Wilbert Berendsen wrote: > I' prefer: > > value = (foo.bar()['first'][0] * baz.quux(1, 2)[5:9] + > calculate_number(10, 20) * forbulate(500, 360)) I prefer using a two-dimensional layout to make the expression structure more obvious: value = \ ( foo

Re: Idioms and Anti-Idioms Question

2009-06-22 Thread Wilbert Berendsen
Op maandag 22 juni 2009, schreef Lawrence D'Oliveiro: > value = \ > ( > foo.bar()['first'][0] * baz.quux(1, 2)[5:9] > + > calculate_number(10, 20) * forbulate(500, 360) > ) I' prefer: value = (foo.bar()['first'][0] * baz.quux(1, 2)[5:9] + c

Re: Idioms and Anti-Idioms Question

2009-06-22 Thread Lawrence D'Oliveiro
In message , Lie Ryan wrote: > The preferred style is to put the binary operators before the line-break > ... Not by me. I prefer using a two-dimensional layout to make the expression structure more obvious: value = \ ( foo.bar()['first'][0] * baz.quux(1, 2)[5:9]

Re: Idioms and Anti-Idioms Question

2009-06-21 Thread Lie Ryan
Ben Charrow wrote: > I have a question about the "Using Backslash to Continue Statements" in > the howto "Idioms and Anti-Idioms in Python" > (http://docs.python.org/howto/doanddont.html#using-backslash-to-continue-statements) > > > It says: > > "...if the code was: > > value = foo.bar()['first

Re: Idioms and Anti-Idioms Question

2009-06-21 Thread Steven D'Aprano
On Mon, 22 Jun 2009 00:14:50 -0400, Ben Charrow wrote: > I have a question about the "Using Backslash to Continue Statements" in > the howto "Idioms and Anti-Idioms in Python" > (http://docs.python.org/howto/doanddont.html#using-backslash-to- continue-statements) > > > It says: > > "...if the c