Path: csiph.com!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Using 'Or' Date: Sat, 16 Jan 2016 14:41:07 +0200 Organization: A noiseless patient Spider Lines: 24 Message-ID: <87bn8lae8s.fsf@elektro.pacujo.net> References: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="b7cb1518d23ec19d482dcc9c31d30fdd"; logging-data="32167"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX181Gy0NcXNGLKtHP0wgoIld" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) Cancel-Lock: sha1:BYiepBkecuysJfwsB+EtthMNhyQ= sha1:qeaics3NiQ0XDfWOwA/tHbESuaQ= Xref: csiph.com comp.lang.python:101803 Christian Gollwitzer : > Am 15.01.16 um 21:24 schrieb Kitten Corner: >> print('i like pie' or 'i like donuts') > >> it only does the thing that's before the 'or', please help! > > I think you misunderstand what "or" does. It evaluates the first > expression, and if this is false, it evaluates the second. The fact that "or" doesn't return True but one of its arguments is a great feature. Too bad "any" doesn't follow suit: >>> any(x for x in ('a', 'b')) True >>>> import random >>>> random.choice(('donuts','apples')) > 'donuts' Well, there's that. "Any" works more nicely with generators, though. Marko