Two question from a newbie

Tim Ottinger tottinge at concentric.net
Thu Feb 24 15:00:09 CET 2000


On Sun, 13 Feb 2000 00:45:59 +1100, "Jason Stokes"
<jstok at bluedog.apana.org.au> wrote:
>>> if ( x.mode == "view" or x.mode == "modify):
[...]
>>if x.mode in ("view", "modify"):
>
>
>I don't see that this idiom has that much to recommend it.  Mr Drake's
>version is clear in that we're comparing x.mode with two modes -- "view" and
>"modify".  Your version attempts to *find* x.mode in the tuple ("view",
>"modify") and executes the sub-bock if successful.  The intention of the
>first example is immediately apparent.  The intention of the second is not
>so immediate, so it must lose out if you want to write maximally
>comprehendable code.


To each his own, I guess. 

I found that the intent of the first one was only more comprehensible
to a programmer skilled in C-like languages.

The second is more explicit, and doesn't have any doubled symbols. 
It's more English-like. 

I don't know how they compare in performance, but my son can read the
second, whereas he's intimidated by the first. He's in 3rd grade, and
never programmed before.

Tim



More information about the Python-list mailing list