PEP308: a call for usability studies (was Re: Update to PEP308: if-then-else expression)

Carel Fellinger carel.fellinger at
Thu Feb 13 00:26:09 CET 2003

On Tue, Feb 11, 2003 at 10:04:20PM +0000, Raymond Hettinger wrote:
> [Raymond Hettinger
> > > * (if <condition>: <expression1> else: <condition2>) is in vogue.
> [Samuele Pedroni]
> > - 10
> Wow, that's pretty strong.
> To make it stick, it helps to post your reasons.
> My own reasons for avoiding this one are:

why stick with our feelings where the pythonic way is to have
usability studies:) So I wook up my daughters, they know about
HTML and a little javascript and are big fans of Monty Python.

I showed them the following snippets:

1)   a = 1

2)   if a == 1:
        b = 2
        b = 3

3)   b = 2 if a==1 else 3

4)   b = (if a==1: 2 else: 3)

I showed 1) to refresh their knowledge of assignment (years ago I tried
in vein to get them to code using Python).  They looked insulted when I
asked them what a was.

Then I showed 2) and asked what b was.  Again insulted looks and the right

Next I showed 3) and asked for b.  As anwser they started to read it
aloud in dutch; realising that it's silly to explain something by
repeating it they got to more verbose reformulations indicating they
understood what was going on.

Next I showed 4) and asked the same....
Bafflement, stupified, it took them ages (okee, seconds) to read it.
Mirte said she doubted she could understand it without having seen 2
and 3.  Merel questioned the colons, she expected something that stood
on its own (like a statement) after the collon, not merely a value.

When I later on tried it on my wife (happily computer illiterate, I
had to explain the if statement:), snippet 3 posed no problems, but
again bafflement looking at snippet 4.  So much line noise, she
complained, what's with those brackets and those collons, and then
the value for b hidden somewhere in that noise.

All three prefered 2, had no problems understanding 3, but it took
them quit some time to understand 4.  Even more remarkably, as they
claimed that having seen snippets 2 and 3 they already knew the anwser.

Not quite what you would have expected, hm.  I really hope someone
steps forward and does some usability test before we grow a new wart
on this beautifull language.

> All of these problems are solved by using punctuation
> instead of keywords:
>     c ?? a || b          c ? a : b        c ? a ! b

I didn't try these yet, will have to wait till tomorrow as the twins
are fast asleep now.

groetjes, carel

More information about the Python-list mailing list