PEP 308: Alternative conditional operator forms

Erik Max Francis max at alcyone.com
Thu Feb 13 18:08:53 EST 2003


Michele Simionato wrote:

> I tested the proposed syntax showing it to my girlfriend (see the
> thread
> on usability studies). She is an happy non-programmer and found the
> 
> z=(if C: x else: y)
> 
> construct very hard to read, much harder than
> 
> z=x if C else y

No offense to your girlfriend, but I'm not sure this is useful
information.  It is irrelevant what a _non_-programmer thinks about a
particle syntax.  It's relevant what a _beginning_ programmer thinks
about a particular syntax, in particular a beginning programmer _in that
language_.

In that context, I have no doubt that a beginning Python programmer --
who has certainly been introduced the if...else construct in statements
-- will be able to easily divine what

	safeSqrt = (if x > 0: math.sqrt(x) else: 0.0)

means.

> The reason of the unreadability were the colons, ...

There are lots of people that don't know Python who find the use of
colons strange or confusing.  This doesn't constitute good data on
whether _this_ syntax is good for _this_ language, in my opinion.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, USA / 37 20 N 121 53 W / &tSftDotIotE
/  \ Sentimentality is a superstructure covering brutality.
\__/ C.G. Jung
    Esperanto reference / http://www.alcyone.com/max/lang/esperanto/
 An Esperanto reference for English speakers.




More information about the Python-list mailing list