PEP-308 a "simplicity-first" alternative

Steven Taschuk staschuk at telusplanet.net
Fri Feb 14 21:58:30 CET 2003


Quoth Erik Max Francis:
  [...]
> However, the use of the _idiom_ combining the two in order to attempt to
> the effect of a conditional operator -- `C and x or y' -- is idiomatic,
> unreadable, and _wrong_.  [...]
> For that reason, your `C and {x} or y' suggestion is simply more
> idiomatic and unreadable [...]

Idiomatic != unreadable.  Idiomatic != incomprehensible until
explained.  In fact, part of fluency in a language is knowing its
idioms and using them *in preference to* other ways of saying the
same things.

For example, I once saw a loop such as the following in a Python
newbie's code:
	i = 0
	while i < len(some_list):
		print some_list[i]
		i = i + 1
Though correct and clear, this is a bad way to write the loop,
because it's not idiomatic: nobody writes loops of this sort in
this way.  Thus the reader has to stop and study for a moment to
see just what the loop is doing, and might even scrutinize it to
be sure there's no reason it was written in this strange way.
	for x in some_list:
		print x
is equally correct and clear, but more idiomatic and hence better.
Fluent readers will parse it correctly in an instant and without
conscious thought, leaving their faculties free to think about
other aspects of the code.

-- 
Steven Taschuk           | "I may be wrong but I'm positive."
staschuk at telusplanet.net |       _Friday_, Robert A. Heinlein





More information about the Python-list mailing list