Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #38439
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.mb-net.net!open-news-network.org!.POSTED!not-for-mail |
|---|---|
| From | Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> |
| Newsgroups | comp.lang.python |
| Subject | Re: Implicit conversion to boolean in if and while statements |
| Date | Fri, 08 Feb 2013 12:11:20 +0100 |
| Organization | A newly installed InterNetNews server |
| Lines | 22 |
| Message-ID | <kf2mgm$a3o$1@r03.glglgl.gl> (permalink) |
| References | <mailman.2132.1342341291.4697.python-list@python.org> <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> <mailman.2144.1342371768.4697.python-list@python.org> <50037eab$0$29995$c3e8da3$5496439d@news.astraweb.com> <50047A84.6020208@gmail.com> <mailman.2189.1342471591.4697.python-list@python.org> <5004b543$0$29978$c3e8da3$5496439d@news.astraweb.com> <mailman.2195.1342490275.4697.python-list@python.org> <5004ec84$0$11116$c3e8da3@news.astraweb.com> <mailman.2201.1342502395.4697.python-list@python.org> <50050f70$0$30002$c3e8da3$5496439d@news.astraweb.com> <mailman.2203.1342513414.4697.python-list@python.org> <21fcdb92-20e3-428b-b06b-057065a4ab25@oo8g2000pbc.googlegroups.com> <2ab8f33d-d515-4e41-bd1a-1d6e1bc87383@googlegroups.com> |
| NNTP-Posting-Host | 2001:41d0:1:22b:41:7b8a:475d:5610 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | gwaiyur.mb-net.net 1360321982 22059 2001:41d0:1:22b:41:7b8a:475d:5610 (8 Feb 2013 11:13:02 GMT) |
| X-Complaints-To | abuse@open-news-network.org |
| NNTP-Posting-Date | Fri, 8 Feb 2013 11:13:02 +0000 (UTC) |
| User-Agent | Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/17.0 Thunderbird/17.0 |
| X-User-ID | U2FsdGVkX18EQMHrJ8S3CVND3OpO22Ael+zJxsbMk1BJf6RbcWLxZYBrhBhiJMJcx9eTunzTxxw= |
| In-Reply-To | <2ab8f33d-d515-4e41-bd1a-1d6e1bc87383@googlegroups.com> |
| Cancel-Lock | sha1:I8IkWu8hPOToZ1GKeQeUMDOqFeA= |
| Xref | csiph.com comp.lang.python:38439 |
Show key headers only | View raw
Am 08.02.2013 07:29 schrieb Rick Johnson:
> Consider this:
>
> if connect("my:db") as db:
> <do something>
>
> No need to make a call and then test for the validity of the call when you can do both simultaneously AND intuitively.
Would be great, but can be emulated with
def ifiter(x):
if x: yield x
for db in ifiter(connect("my:db")):
<do sth with db>
Is not very intuitive, however, but does its job.
Thomas
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Implicit conversion to boolean in if and while statements Rick Johnson <rantingrickjohnson@gmail.com> - 2013-02-07 22:29 -0800 Re: Implicit conversion to boolean in if and while statements Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2013-02-08 12:11 +0100 Re: Implicit conversion to boolean in if and while statements alex23 <wuwei23@gmail.com> - 2013-02-10 18:38 -0800
csiph-web