"Usability, the Soul of Python"

Russ P. russ.paielli at gmail.com
Tue Mar 30 22:03:37 CEST 2010


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... at 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)




More information about the Python-list mailing list