Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #46172
| Date | 2013-05-27 16:13 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: Short-circuit Logic |
| References | <knup72$juf$1@ger.gmane.org> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2235.1369635220.3114.python-list@python.org> (permalink) |
On 27May2013 06:59, Vito De Tullio <vito.detullio@gmail.com> wrote: | Cameron Simpson wrote: | > if s is not None and len(s) > 0: | > ... do something with the non-empty string `s` ... | > | > In this example, None is a sentinel value for "no valid string" and | > calling "len(s)" would raise an exception because None doesn't have | > a length. | | obviously in this case an `if s: ...` is more than sufficient :P :P My fault for picking too similar a test. Cheers, -- Cameron Simpson <cs@zip.com.au> Death is life's way of telling you you've been fired. - R. Geis
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Short-circuit Logic Cameron Simpson <cs@zip.com.au> - 2013-05-27 16:13 +1000
csiph-web