Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: MRAB Newsgroups: comp.lang.python Subject: Re: Just starting to learn Python, and encounter a problem Date: Sat, 23 Jul 2016 20:06:31 +0100 Lines: 32 Message-ID: References: <9d0a21d9-dddd-c473-f468-9473612591ca@mrabarnett.plus.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: news.uni-berlin.de 1WiviK2V6A9+cCpF/G7wswr3tYXHlaDcuZ6A8HFgnYgw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'true,': 0.04; 'subject:Python': 0.05; 'false,': 0.07; 'evaluates': 0.16; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'non-empty': 0.16; 'received:192.168.1.4': 0.16; 'received:84.93': 0.16; 'received:84.93.230': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'wrote:': 0.16; 'string': 0.17; 'have:': 0.18; '(the': 0.22; 'subject:problem': 0.22; 'suppose': 0.22; 'header:In-Reply-To:1': 0.24; 'header:User-Agent:1': 0.26; 'example': 0.26; 'received:84': 0.32; '(i.e.': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'of:': 0.66; 'therefore': 0.67; 'strings)': 0.84; 'subject:learn': 0.84; 'subject:Just': 0.91 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=DaJVkblW c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=IkcTkHD0fZMA:10 a=UaR_ZnMUNfQ35Z-hT1sA:9 X-AUTH: mrabarnett@:2500 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <9d0a21d9-dddd-c473-f468-9473612591ca@mrabarnett.plus.com> X-Mailman-Original-References: Xref: csiph.com comp.lang.python:111797 On 2016-07-23 19:18, gst wrote: > Heuh case 2 : > > "String1" or "String2" > > Evaluates to "String1" ? > Suppose you have: x or y If bool(x) returns True, then the result will be x, else the result will be y. Example 1: bool("String1") returns True, therefore the result of: "String1" or "String2" is "String1". Example 2: bool("") returns False, so the result of: "" or "String2" is "String2". (The empty string "" is considered 'false-y'; all other strings (i.e. all non-empty strings) are considered 'true-y'.)