Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

"Usability, the Soul of Python"

0 views
Skip to first unread message

Jonathan Hayward

unread,
Mar 29, 2010, 3:41:15 PM3/29/10
to
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/

The basic suggestion is that much of what works well in Python has
something to do with the usability it offers programmers.

Enjoy.

--
Jonathan Hayward, christos.jon...@gmail.com
An Orthodox Christian author: theology, literature, et cetera.
My award-winning collection is available for free reading online:
I invite you to visit my main site at http://JonathansCorner.com/

Phlip

unread,
Mar 29, 2010, 3:45:39 PM3/29/10
to
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/
>
> The basic suggestion is that much of what works well in Python has
> something to do with the usability it offers programmers.

You mean like...

Order.has_many :line_items

?

Oops, sorry, wrong language. My bad!

--
Phlip
http://zeekland.zeroplayer.com/

John Nagle

unread,
Mar 29, 2010, 8:30:05 PM3/29/10
to
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.

By the same author: "The Case For Uncreative Web Design", which
has no examples.

John Nagle

Jean-Michel Pichavant

unread,
Mar 30, 2010, 5:03:06 AM3/30/10
to John Nagle, pytho...@python.org
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 ?

JM

Malte Dik

unread,
Mar 30, 2010, 7:17:21 AM3/30/10
to
> Why is it bad ?
>

Not working code, examples, that are weird to read, and a lot of text :)


Alf P. Steinbach

unread,
Mar 30, 2010, 7:40:22 AM3/30/10
to
* Jean-Michel Pichavant:

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)

Russ P.

unread,
Mar 30, 2010, 4:03:37 PM3/30/10
to
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);
}

> habit I'd picked up in Pascal, from very naïve considerations of parse nesting

Robert Fendt

unread,
Mar 30, 2010, 6:32:41 PM3/30/10
to
And thus spake "Alf P. Steinbach" <al...@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

Chris Rebert

unread,
Mar 30, 2010, 7:20:32 PM3/30/10
to pytho...@python.org

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

Lawrence D'Oliveiro

unread,
Mar 30, 2010, 7:23:46 PM3/30/10
to
In message <20100331003...@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

Lawrence D'Oliveiro

unread,
Mar 30, 2010, 7:32:42 PM3/30/10
to
In message <hosnrh$6na$1...@news.eternal-september.org>, Alf P. Steinbach
wrote:

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

Having used so many different languages over the years, I have settled on a
reasonably common set of indentation conventions that work across most of
them.

The only one that currently annoys me is JavaScript, because its semicolons-
are-optional rule means that certain ways I write statements continued
across multiple lines are interpreted as prematurely completing the
statement.

In revenge for that, I refuse to put optional semicolons in my JavaScript
code altogether.

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

I use four. Why four? Because it’s divisible by two. Because I use the half-
step (two columns) for lines containing nothing but bracketing symbols:

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);
} /*for*/

for i := 99 downto 1 do
begin
writeln(i, " slabs of spam in my mail!");
writeln(i, " slabs of spam,");
writeln("Send one to abuse and Just Hit Delete,");
writeln(i - 1, " slabs of spam in my mail!\n\n")
end {for}

Actually this looks like another opportunity for a loop-with-exit-in-the-
middle:

for (i = 99;;)


{
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");

--i;
if (i == 0)
break;
printf("%d slabs of spam in my mail!\n\n", i);
} /*for*/

Steve Holden

unread,
Mar 30, 2010, 8:12:54 PM3/30/10
to pytho...@python.org
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/
>
> The basic suggestion is that much of what works well in Python has
> something to do with the usability it offers programmers.
>
> Enjoy.
>
Now try another one called "Brevity, the Soul of Technical Writing: An
Introduction to Making Yourself Understood Through the Eyes of Readability".

What I managed to read seemed to be making worthwhile points, but I felt
a bit like I was wading through a steaming pile of irrelevant verbiage
that actually made it more difficult to extract the useful nuggets.

Bravo for undertaking this task, but I do feel the treatment needs work
from a good copy editor.

Of course you have to take into account my allergy to folksy metaphors
and meandering discourse. Had I chosen your style I might instead have
written the criticism above as:

"""
I would like to begin my critique of this paper with a feature that many
competent technical writers completely fail to appreciate: why brevity
is desirable in technical writing.

Technical writing is not, of course, the only form of writing that there
is. People have been writing ever since the first caveman decided he
could leave marks on the wall of a cave to indicate that food could be
had in the vicinity. The basic concept of brevity is that you should
not, as a writer, use superfluous words because if you do then the
reader will always be in doubt about which parts of your discourse are
meaningful and which are merely decoration.

...
"""

And so on. As I say, this may be criticism dictated by my personal
taste, but I feel you could condense the presentation considerably to
good effect. Sorry if this offends. It's meant to help.

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
See PyCon Talks from Atlanta 2010 http://pycon.blip.tv/
Holden Web LLC http://www.holdenweb.com/
UPCOMING EVENTS: http://holdenweb.eventbrite.com/

Cameron Simpson

unread,
Mar 30, 2010, 9:04:43 PM3/30/10
to Chris Colbert, pytho...@python.org
On 30Mar2010 10:25, Chris Colbert <scco...@gmail.com> wrote:
| not really, the int will eventually overflow and cycle around ;)
|
| On Tue, Mar 30, 2010 at 8:11 AM, Xavier Ho <con...@xavierho.com> wrote:
|
| > Did no one notice that

| > for(i = 99; i > 0; ++i)
| > Gives you an infinite loop (sort of) because i starts a 99, and increases
| > every loop?

And here we see the strength of the Usability example; in Python it
won't overflow, rather seguing seamlessly into an increasing expensive
arbitrary sized int. Though most machines will eventually run out of
memory to hold it...
--
Cameron Simpson <c...@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Surely it was of this place, now Cambridge but formerly known by the name of
Babylon, that the prophet spoke when he said, 'the wild beasts of the desert
shall dwell there, and their houses shall be full of doleful creatures, and
owls shall build there, and satyrs shall dance there.'
- Thomas Gray (1716-1771)

John Nagle

unread,
Mar 31, 2010, 2:05:58 PM3/31/10
to
Alf P. Steinbach 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:

The last time I ran a C++ project, I just had everyone run their
code through Artistic Style ("http://astyle.sourceforge.net") with
"--style=ansi". No more inconsistencies.

John Nagle

0 new messages