From: Alf P. Steinbach on
* Jean-Michel Pichavant:
> John Nagle wrote:
>> Jonathan Hayward wrote:
>>> I've posted "Usability, the Soul of Python: An Introduction to the
>>> Python Programming Language Through the Eyes of Usability", at:
>>>
>>> http://JonathansCorner.com/python/
>>
>> No, it's just a rather verbose introduction to Python, in dark brown
>> type on a light brown background. One could write a good paper on this
>> topic, but this isn't it.
>>
>>
>> John Nagle
> Why is it bad ?

Consider


<quote>
From a usability standpoint, the braces go with the lines to print out the
stanza rather than the for statement or the code after, so the following is best:

for(i = 99; i > 0; ++i)
{
printf("%d slabs of spam in my mail!\n", i);
printf("%d slabs of spam,\n", i);
printf("Send one to abuse and Just Hit Delete,\n");
printf("%d slabs of spam in my mail!\n\n", i + 1);
}
</quote>


This is just unsubstantiated opinion, but worse, it makes a tacit assumption
that there is "best" way to do indentation. However, most programmers fall into
that trap, and I've done it myself. In fact, when I worked as a consultant (then
in Andersen Consulting, now Accenture) I used the style above. Petter
Hesselberg, author of "Industrial Strength Windows Programming" (heh, I'm
mentioned) asked my why on Earth I did that, like, nobody does that? It was a
habit I'd picked up in Pascal, from very na�ve considerations of parse nesting
levels, a kind of misguided idealism instead of more practical pragmatism, but
since I realized that that was an incredibly weak argument I instead answered by
pointing towards Charles Petzold's code in his "Programming Windows" books. And
amazingly I was allowed to continue using this awkward and impractical style.

I may or may not have been responsible for the similarly impractical compromise
convention of using three spaces per indentation level. At least, in one big
meeting the question about number of spaces was raised by the speaker, and I
replied from the benches, just in jest, "three!". And that was it (perhaps).


Cheers,

- Alf (admitting to earlier mistakes)
From: Russ P. on
According to Wikipedia, this is called the Whitesmith style:

for(i = 99; i > 0; ++i)
{
printf("%d slabs of spam in my mail!\n", i);
printf("%d slabs of spam,\n", i);
printf("Send one to abuse and Just Hit Delete,\n");
printf("%d slabs of spam in my mail!\n\n", i + 1);
}

I agree with the Mr. Hayward that it is preferable to the more common
K&R style, because the braces do not violate and visually clutter the
logical indentation structure. It looks more like Python. The deeper
the level of nesting, the more this style reduces visual clutter
compared to the conventional style.

A slightly better style, in my opinion, is the Banner style:

for(i = 99; i > 0; ++i) {
// a blank line here is optional
printf("%d slabs of spam in my mail!\n", i);
printf("%d slabs of spam,\n", i);
printf("Send one to abuse and Just Hit Delete,\n");
printf("%d slabs of spam in my mail!\n\n", i + 1);
}


On Mar 30, 4:40 am, "Alf P. Steinbach" <al...(a)start.no> wrote:
> * Jean-Michel Pichavant:
>
> > John Nagle wrote:
> >> Jonathan Hayward wrote:
> >>> I've posted "Usability, the Soul of Python: An Introduction to the
> >>> Python Programming Language Through the Eyes of Usability", at:
>
> >>>    http://JonathansCorner.com/python/
>
> >>    No, it's just a rather verbose introduction to Python, in dark brown
> >> type on a light brown background.  One could write a good paper on this
> >> topic, but this isn't it.
>
> >>                 John Nagle
> > Why is it bad ?
>
> Consider
>
> <quote>
>  From a usability standpoint, the braces go with the lines to print out the
> stanza rather than the for statement or the code after, so the following is best:
>
> for(i = 99; i > 0; ++i)
>      {
>      printf("%d slabs of spam in my mail!\n", i);
>      printf("%d slabs of spam,\n", i);
>      printf("Send one to abuse and Just Hit Delete,\n");
>      printf("%d slabs of spam in my mail!\n\n", i + 1);
>      }
> </quote>
>
> This is just unsubstantiated opinion, but worse, it makes a tacit assumption
> that there is "best" way to do indentation. However, most programmers fall into
> that trap, and I've done it myself. In fact, when I worked as a consultant (then
> in Andersen Consulting, now Accenture) I used the style above. Petter
> Hesselberg, author of "Industrial Strength Windows Programming" (heh, I'm
> mentioned) asked my why on Earth I did that, like, nobody does that? It was a
> habit I'd picked up in Pascal, from very naïve considerations of parse nesting
> levels, a kind of misguided idealism instead of more practical pragmatism, but
> since I realized that that was an incredibly weak argument I instead answered by
> pointing towards Charles Petzold's code in his "Programming Windows" books. And
> amazingly I was allowed to continue using this awkward and impractical style.
>
> I may or may not have been responsible for the similarly impractical compromise
> convention of using three spaces per indentation level. At least, in one big
> meeting the question about number of spaces was raised by the speaker, and I
> replied from the benches, just in jest, "three!". And that was it (perhaps).
>
> Cheers,
>
> - Alf  (admitting to earlier mistakes)

From: Robert Fendt on
And thus spake "Alf P. Steinbach" <alfps(a)start.no>
Tue, 30 Mar 2010 13:40:22 +0200:

> <quote>
> From a usability standpoint, the braces go with the lines to print out the
> stanza rather than the for statement or the code after, so the following is best:
>
> for(i = 99; i > 0; ++i)
> {
> printf("%d slabs of spam in my mail!\n", i);
> printf("%d slabs of spam,\n", i);
> printf("Send one to abuse and Just Hit Delete,\n");
> printf("%d slabs of spam in my mail!\n\n", i + 1);
> }
> </quote>

I liked this one even more:

<quote>
One way of writing the same code in Python would be:

count = 99
while count > 0:
print u'%d slabs of spam in my mail!' % count
print u'%d slabs of spam,' % count
print u'Send one to abuse and Just Hit Delete,'
count += 1
print u'%d slabs of spam in my mail!' % count
print u''

The braces are gone, and with them the holy wars. Whatever brace
styles Python programmers may happen to use in languages with
braces, all the Python code looks the same, and while the major
brace styles illustrated above are a few of many ways the C code
could be laid out, there's only one real way to do it.
</quote>

Has the fact changed that Python does not care about (1) how
many characaters you use for indentation, (1a) you can use tabs
OR spaces, (2) indentation does not have to be consistent across
a module, (3) not even across a file, (4) even in nested blocks
and (5) you can even switch from spaces to tabs and back in the
same file? So much for 'all the Python code looks the same'.

In general I do not really see what qualifies the author for an
article on Python's usability. On the same site one can also
find a lot of things e.g. on intelligent design and creationism,
and the 'The Case For Uncreative Web Design' in which the author
advocates 'uncreative' (in the sense of non-distracting) web
design while at the same time showcasing quite the opposite:
suffice it to say I found most essays rather difficult to read
from a technical point of view, to say nothing about the content.

Regards,
Robert

From: Chris Rebert on
On Tue, Mar 30, 2010 at 3:32 PM, Robert Fendt <no.spam(a)local.local> wrote:
> And thus spake "Alf P. Steinbach" <alfps(a)start.no>
> Tue, 30 Mar 2010 13:40:22 +0200:
>> <quote>
>>  From a usability standpoint, the braces go with the lines to print out the
>> stanza rather than the for statement or the code after, so the following is best:
>>
>> for(i = 99; i > 0; ++i)
>>      {
>>      printf("%d slabs of spam in my mail!\n", i);
>>      printf("%d slabs of spam,\n", i);
>>      printf("Send one to abuse and Just Hit Delete,\n");
>>      printf("%d slabs of spam in my mail!\n\n", i + 1);
>>      }
>> </quote>
>
> I liked this one even more:
>
> <quote>
> One way of writing the same code in Python would be:
>
> count = 99
> while count > 0:
>    print u'%d slabs of spam in my mail!' % count
>    print u'%d slabs of spam,' % count
>    print u'Send one to abuse and Just Hit Delete,'
>    count += 1
>    print u'%d slabs of spam in my mail!' % count
>    print u''
>
> The braces are gone, and with them the holy wars. Whatever brace
> styles Python programmers may happen to use in languages with
> braces, all the Python code looks the same, and while the major
> brace styles illustrated above are a few of many ways the C code
> could be laid out, there's only one real way to do it.
> </quote>
>
> Has the fact changed that Python does not care about (1) how
> many characaters you use for indentation, (1a) you can use tabs
> OR spaces, (2) indentation does not have to be consistent across
> a module, (3) not even across a file, (4) even in nested blocks
> and (5) you can even switch from spaces to tabs and back in the
> same file? So much for 'all the Python code looks the same'.

Since we're harping on block delimitation, I'll plug a post I did on
the subject a little while ago:
http://blog.rebertia.com/2010/01/24/of-braces-and-semicolons/

Hopefully it's more thorough than the OP's.

Cheers,
Chris
From: Lawrence D'Oliveiro on
In message <20100331003241.47fa91f6(a)vulcan.local>, Robert Fendt wrote:

> The braces are gone, and with them the holy wars.

Let me start a new one. I would still put in some kind of explicit indicator
of the end of the grouping construct:

count = 99
while count > 0:
print u'%d slabs of spam in my mail!' % count
print u'%d slabs of spam,' % count
print u'Send one to abuse and Just Hit Delete,'
count += 1
print u'%d slabs of spam in my mail!' % count
print u''
#end while