[Edu-sig] RE: Long Boolean expressions

John Posner jjp@connix.com
Tue, 6 Jun 2000 13:00:50 -0400


Hi, Gordon --

I agree with your analysis almost completely. I was aiming my implementation
at the person who is (1) learning computer programming and (2) learning
Python.

My one (slight) objection is your wanting to change:

 * the comparison operation "> 0", which is firmly in the numerical realm

 * to the comparison operation "!= 0", which is more in the logical realm
  ("not equal to FALSE")

But again, I have pedagogy in mind, not "Boolean purity". :-)

-John
--
John Posner, Editor           jjp@oreilly.com
O'Reilly & Associates         860-663-3147


----------
  I can't say that I agree.  First of all, this is not a quirk of
  Python, this is a feature.  It is also present in many, many other
  programming languages.  Secondly, this is a style widely used by
  Python hackers and other end-users (of Python, not of Python
  scripts), so while the long form might be appropriate in the context
  of learning Python syntax, it is not during application, except, of
  course, by end-users who are having difficulty with the more concise
  formation.  Thus, using the long form only hurts others by not
  forcing them to learn the style that they are going to encounter when
  reading other people's code.  Finally, while the '> 0' bit part works
  in this situation, it is not very robust since any, to quote,
  "non-zero/non-empty" is true.  Thus, '!= 0' should be used instead of
  '> 0', so that this long form will work in all situations.
----------

--
John Posner, Editor           jjp@oreilly.com
O'Reilly & Associates         860-663-3147