Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Error in or Date: Fri, 12 Jun 2015 12:55:08 +0300 Organization: A noiseless patient Spider Lines: 17 Message-ID: <87k2v91car.fsf@elektro.pacujo.net> References: <3bf5dd52-c698-4392-be2b-5c0aeefc3cd3@googlegroups.com> <557aa956$0$11125$c3e8da3@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="23997"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18z9yaOvjWaGfiqNe5xKku2" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:a0oJ4vl0M6Vbu5mua3z2EURrnvo= sha1:vKF/jwNjsgyIYaksm8671Rvw0sk= Xref: csiph.com comp.lang.python:92509 Steven D'Aprano : > This is better written as: > > if any(substr in inp1 for substr in > ['AND', 'OR', 'NOT', '>', '&', 'MAYBE', '(', '*', ' " ']): > print 'FINE' Or, equivalently: for substr in ['AND', 'OR', 'NOT', '>', '&', 'MAYBE', '(', '*', ' " ']: if substr in inp1: print('FINE') break Marko