Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #111797
| From | MRAB <python@mrabarnett.plus.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Just starting to learn Python, and encounter a problem |
| Date | 2016-07-23 20:06 +0100 |
| Message-ID | <mailman.86.1469300796.22221.python-list@python.org> (permalink) |
| References | <ac35006b-ab2e-44f1-b896-cd57d9689c73@googlegroups.com> <CAP1rxO6F0q2dOd1T_wV0=PNN6Gny1wFDQ3GUw5Js-7pTaEwREQ@mail.gmail.com> <mailman.50.1469198194.22221.python-list@python.org> <e6f7d426-bbb8-47d8-9326-2d34d4ed4737@googlegroups.com> <9d0a21d9-dddd-c473-f468-9473612591ca@mrabarnett.plus.com> |
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'.)
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Just starting to learn Python, and encounter a problem Zagyen Leo <zagyen@gmail.com> - 2016-07-22 06:59 -0700
Re: Just starting to learn Python, and encounter a problem Random832 <random832@fastmail.com> - 2016-07-22 10:30 -0400
Re: Just starting to learn Python, and encounter a problem Zagyen Leo <zagyen@gmail.com> - 2016-07-22 23:13 -0700
Re: Just starting to learn Python, and encounter a problem Bob Gailer <bgailer@gmail.com> - 2016-07-22 10:36 -0400
Re: Just starting to learn Python, and encounter a problem gst <g.starck@gmail.com> - 2016-07-23 11:18 -0700
Re: Just starting to learn Python, and encounter a problem MRAB <python@mrabarnett.plus.com> - 2016-07-23 20:06 +0100
Re: Just starting to learn Python, and encounter a problem Steven D'Aprano <steve@pearwood.info> - 2016-07-24 11:58 +1000
Re: Just starting to learn Python, and encounter a problem Gordon Levi <gordon@address.invalid> - 2016-07-23 00:37 +1000
Re: Just starting to learn Python, and encounter a problem justin walters <walters.justin01@gmail.com> - 2016-07-22 08:04 -0700
Re: Just starting to learn Python, and encounter a problem MRAB <python@mrabarnett.plus.com> - 2016-07-22 16:08 +0100
csiph-web