question about True values

Donn Cave donn at u.washington.edu
Thu Oct 26 12:58:07 EDT 2006


In article <mailman.1264.1161861732.11739.python-list at python.org>,
 Steve Holden <steve at holdenweb.com> wrote:
...
> Maybe so, but that "rule" (and let's not forget that the zen is not 
> actually a set of prescriptive rules but rather guidelines for the 
> informed) is immediately preceded by the most important "rule" of all: 
> "Beautiful is better than ugly". Nobody will shout at you (well, 
> hopefully, not on this list they won't) for writing
> 
>    if my_list != []:
>      ...
> 
> in your code, but if they have to incorporate it into their own they 
> will almost certainly reduce it to
> 
>    if my_list:
>      ....
> 
> It's just idiomatic in Python, the same way that "'Sup?" is idiomatic in 
> English (or what passes for it nowadays ;-) but grates on those who 
> aren't used to hearing it.

It is idiomatic, but not _just_ idiomatic.  The former requires
a list object (or a tricky __eq__()), the latter works with a variety
of objects, exhibiting a useful polymorphism.

As for similarities between computer programming languages
and natural languages, I think that breaks down pretty fast.

Part of the problem is something that pinches Python pretty
hard right here, a lack of words that conveniently express
important concepts in the language.  A few posts back, Carl
Banks made a distinction between "equaling" and "being", and
if I understood that right, it expresses a fundamental notion
about the meaning of Python's "if", "while" etc. statements.
Unfortunately, though, English conflates existence and identity
in this word ("be"), so it's not going to serve our purposes
very well, and when it comes to words like "if" -- well, we
just have to use what we have.

If there were better words to use with the notion of
"something-ness", I think we would see booleans as a silly
thing of little use to Python programmers.  If you can see
"if" and "while" as constructs that respond to something-ness,
you will appreciate idiomatic Python better, because that
arguably is just what it's about.

   Donn Cave, donn at u.washington.edu



More information about the Python-list mailing list