Two question from a newbie
moshez at math.huji.ac.il
Fri Feb 11 18:07:48 CET 2000
On Fri, 11 Feb 2000, Fred L. Drake, Jr. wrote:
> > 1.) How do I implement ORs and ANDs in an if-statment?
> > - e.g. I'd like to have this C-code in Python:
> > if (x.mode == "view" || x.mode == "modify")
> > myMode = x.mode;
> if (x.mode == "view" or x.mode == "modify"):
> myMode = x.mode
Apparently Fred is hacking too much C these days, otherwise he'd
encourage you to use Python (rather then C-in-Python):
if x.mode in ("view", "modify"):
myMode = x.mode
(I saved you one time of writing x.mode. One less bug when you ch\ange
the name "mode").
Moshe Zadka <mzadka at geocities.com>.
INTERNET: Learn what you know.
Share what you don't.
More information about the Python-list