Two question from a newbie

Moshe Zadka moshez at math.huji.ac.il
Sat Feb 12 13:03:44 EST 2000


On Sun, 13 Feb 2000, Jason Stokes wrote:

<on 

if x.mode == "view" or x.mode == "modify":

vs.

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.  

Well, as with all issues of taste this is highly personal, so I won't let
it degenerate into a long thread. My only reply is that the first
reads as "if x.mode is view of if x.mode is modify", whereas the second
reads as "if x.mode is one of view and modify". I leave it to the reader
to decide which of those two is more readable, and absolutely won't say
anything if anyone claims otherwise.
--
Moshe Zadka <mzadka at geocities.com>. 
INTERNET: Learn what you know.
Share what you don't.





More information about the Python-list mailing list