Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-04 Thread Brian Curtin
On Wed, Jan 4, 2012 at 00:30, Stephen J. Turnbull wrote: > Benjamin Peterson writes: > >  > My goodness, I was trying to make a ridiculous-sounding proposition. > > In this kind of discussion, that's in the same class as "be careful > what you wish for -- because you might just get it." I wish we

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Stephen J. Turnbull
Benjamin Peterson writes: > My goodness, I was trying to make a ridiculous-sounding proposition. In this kind of discussion, that's in the same class as "be careful what you wish for -- because you might just get it." ___ Python-Dev mailing list Python

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Benjamin Peterson
2012/1/3 Stephen J. Turnbull : > Benjamin Peterson writes: >  > Ethan Furman stoneleaf.us> writes: >  > > >  > > Readability also includes more than just the source code; as has already >  > > been stated: > > [diffs elided] > >  > > I find the diff version that already had braces in place much mo

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Stephen J. Turnbull
Benjamin Peterson writes: > Ethan Furman stoneleaf.us> writes: > > > > Readability also includes more than just the source code; as has already > > been stated: [diffs elided] > > I find the diff version that already had braces in place much more > > readable. > > There are much larg

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Benjamin Peterson
Ethan Furman stoneleaf.us> writes: > > Readability also includes more than just the source code; as has already > been stated: > > if(cond) { > stmt1; > + stmt2; > } > > vs. > > -if(cond) > +if(cond) { > stmt1; > + stmt2; > +} > > I find the diff version that already had braces

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Martin v. Löwis
> Readability also includes more than just the source code; as has already > been stated: > > if(cond) { >stmt1; > + stmt2; > } > > vs. > > -if(cond) > +if(cond) { >stmt1; > + stmt2; > +} > > I find the diff version that already had braces in place much more > readable. Is it reall

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Ben Finney
"Stephen J. Turnbull" writes: > Matt Joiner writes: > > > Readability is the highest concern, and this should be at the > > discretion of the contributor. > > That's quite backwards. "Readability" is community property, and has > as much, if not more, to do with common convention as with some

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Ethan Furman
Stephen J. Turnbull wrote: Matt Joiner writes: > Readability is the highest concern, and this should be at the > discretion of the contributor. That's quite backwards. "Readability" is community property, and has as much, if not more, to do with common convention as with some absolute metric

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Stephen J. Turnbull
Matt Joiner writes: > Readability is the highest concern, and this should be at the > discretion of the contributor. That's quite backwards. "Readability" is community property, and has as much, if not more, to do with common convention as with some absolute metric. The "contributor's discret

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Matt Joiner
FWIW I'm against forcing braces to be used. Readability is the highest concern, and this should be at the discretion of the contributor. A code formatting tool, or compiler extension is the only proper handle this, and neither are in use or available. On Tue, Jan 3, 2012 at 7:44 PM, "Martin v. Löw

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-03 Thread Martin v. Löwis
> He keeps leaving them out, I occasionally tell him they should always > be included (most recently this came up when we gave conflicting > advice to a patch contributor). He says what he's doing is OK, because > he doesn't consider the example in PEP 7 as explicitly disallowing it, > I think it's

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Barry Warsaw
On Jan 02, 2012, at 02:08 PM, Guido van Rossum wrote: >The irony is that style guides exist to *avoid* debates like this. Yes, the >choices are arbitrary. Yes, tastes differ. Yes, there are exceptions to the >rules. But still, once a style rule has been set, the idea is to stop >debating and just

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Guido van Rossum
On Mon, Jan 2, 2012 at 4:27 PM, Nick Coghlan wrote: > On Tue, Jan 3, 2012 at 8:32 AM, Raymond Hettinger > wrote: > > Running ``grep -B1 else Objects/*c`` shows that we've happily lived > with a > > mixture of styles for a very long time. > > ISTM, our committers have had good instincts about wh

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Tim Delaney
On 3 January 2012 09:55, Raymond Hettinger wrote: > > On Jan 2, 2012, at 2:09 PM, Tim Delaney wrote: > > I'd also point out that if you're expecting braces, not having them can > make the code less readable. > > > If a programmer's mind explodes when they look at the simple and beautiful > example

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 2, 2012, at 4:27 PM, Nick Coghlan wrote: > With my perception of the status quo corrected, I can stop worrying > about preserving a non-existent consistency. +1 QOTD Raymond ___ Python-Dev mailing list Python-Dev@python.org http://mail.python

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Tue, Jan 3, 2012 at 8:32 AM, Raymond Hettinger wrote: > Running  ``grep -B1 else Objects/*c`` shows that we've happily lived with a > mixture of styles for a very long time. > ISTM, our committers have had good instincts about when braces add clarity > and when they add clutter. > If Nick pushe

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Tue, Jan 3, 2012 at 12:54 AM, Benjamin Peterson wrote: > I think it's fine Nick raised this. PEP 7 is not very explicit about > braces at all. I actually discovered in this thread that I've been misreading PEP 7 for going on 7 years now - I thought the brace usage example *did* use "} else {"

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Ned Batchelder
On 1/2/2012 5:32 PM, Raymond Hettinger wrote: Running ``grep -B1 else Objects/*c`` shows that we've happily lived with a mixture of styles for a very long time. ISTM, our committers have had good instincts about when braces add clarity and when they add clutter. If Nick pushes through an alwa

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 2, 2012, at 2:09 PM, Tim Delaney wrote: > I'd also point out that if you're expecting braces, not having them can make > the code less readable. If a programmer's mind explodes when they look at the simple and beautiful examples in K&R's The C Programming Language, then they've got pro

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 2, 2012, at 12:31 PM, Benjamin Peterson wrote: > I might add that assuming you have braces, PEP 7 would want you to format it > as > > if (cond) { >statement; > } > else { >more_stuff; > } > Running ``grep -B1 else Objects/*c`` shows that we've happily lived with a mixture o

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Tim Delaney
On 3 January 2012 08:50, Larry Hastings wrote: > On 01/02/2012 12:47 AM, Raymond Hettinger wrote: > >> Really? Do we need to have a brace war? >> People have different preferences. >> The standard library includes some of both styles >> depending on what the maintainer thought was cleanest to th

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Guido van Rossum
On Mon, Jan 2, 2012 at 1:50 PM, Larry Hastings wrote: > On 01/02/2012 12:47 AM, Raymond Hettinger wrote: > >> Really? Do we need to have a brace war? >> People have different preferences. >> The standard library includes some of both styles >> depending on what the maintainer thought was cleanes

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Larry Hastings
On 01/02/2012 12:47 AM, Raymond Hettinger wrote: Really? Do we need to have a brace war? People have different preferences. The standard library includes some of both styles depending on what the maintainer thought was cleanest to their eyes in a given context. I'm with Raymond. Code should

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Benjamin Peterson
2012/1/1 Nick Coghlan : > >  if (cond) { >    statement; >  } else { >    statement; >  } I might add that assuming you have braces, PEP 7 would want you to format it as if (cond) { statement; } else { more_stuff; } -- Regards, Benjamin ___ P

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Tres Seaver
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 01/02/2012 01:02 AM, Nick Coghlan wrote: > On Mon, Jan 2, 2012 at 3:04 PM, Scott Dial > wrote: >> On 1/1/2012 11:44 PM, Nick Coghlan wrote: >>> I think it's a recipe for future maintenance hassles when someone >>> adds a second statement to one of

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Benjamin Peterson
2012/1/1 Nick Coghlan : > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements: Python's C code has been dropping braces long before I ever arrived. See this beautiful example in dictobject.c, for example: if (numfree < PyDict_MAXFREELIST && Py_TYPE

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Ned Batchelder
On 1/1/2012 11:44 PM, Nick Coghlan wrote: I've been having an occasional argument with Benjamin regarding braces in 4-line if statements: if (cond) statement; else statement; vs. if (cond) { statement; } else { statement; } He keeps leaving them out, I occas

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Petri Lehtinen
Antoine Pitrou wrote: > I don't like having the else on the same line as the closing brace, > and prefer: > >if (cond) { >statement; >} >else { >statement; >} And this is how it's written in PEP-7. It seems to me that PEP-7 doesn't require braces. But it explicitly

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Antoine Pitrou
On Mon, 2 Jan 2012 14:44:49 +1000 Nick Coghlan wrote: > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements: > > if (cond) > statement; > else > statement; > > vs. > > if (cond) { > statement; > } else { > statement; > } Go

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Mon, Jan 2, 2012 at 6:47 PM, Raymond Hettinger wrote: > Really?  Do we need to have a brace war? > People have different preferences. > The standard library includes some of both styles > depending on what the maintainer thought was cleanest to their eyes in a > given context. If the answer i

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Raymond Hettinger
On Jan 1, 2012, at 8:44 PM, Nick Coghlan wrote: > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements: > > if (cond) >statement; > else >statement; > > vs. > > if (cond) { >statement; > } else { >statement; > } Really? Do we

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-02 Thread Nick Coghlan
On Mon, Jan 2, 2012 at 4:22 PM, Ron Adam wrote: > The problem is only when an additional statement is added to the last > block, not the preceding ones, as the compiler will complain about > those.  So I don't know how the 4 line example without braces is any > worse than a 2 line if without brace

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-01 Thread Ron Adam
On Mon, 2012-01-02 at 14:44 +1000, Nick Coghlan wrote: > I've been having an occasional argument with Benjamin regarding braces > in 4-line if statements: > > if (cond) > statement; > else > statement; > > vs. > > if (cond) { > statement; > } else { > statement; > } >

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-01 Thread Nick Coghlan
On Mon, Jan 2, 2012 at 3:04 PM, Scott Dial wrote: > On 1/1/2012 11:44 PM, Nick Coghlan wrote: >> I think it's a recipe for future maintenance hassles when someone adds >> a second statement to one of the clauses but doesn't add the braces. >> (The only time I consider it reasonable to leave out th

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-01 Thread Scott Dial
On 1/1/2012 11:44 PM, Nick Coghlan wrote: > I think it's a recipe for future maintenance hassles when someone adds > a second statement to one of the clauses but doesn't add the braces. > (The only time I consider it reasonable to leave out the braces is for > one liner if statements, where there's

Re: [Python-Dev] PEP 7 clarification request: braces

2012-01-01 Thread Ben Finney
Nick Coghlan writes: > He keeps leaving [braces] out [when the block is a single statement], > I occasionally tell him they should always be included (most recently > this came up when we gave conflicting advice to a patch contributor). As someone who has maintained his fair share of C code, I a

[Python-Dev] PEP 7 clarification request: braces

2012-01-01 Thread Nick Coghlan
I've been having an occasional argument with Benjamin regarding braces in 4-line if statements: if (cond) statement; else statement; vs. if (cond) { statement; } else { statement; } He keeps leaving them out, I occasionally tell him they should always be included (most