Path: csiph.com!usenet.pasdenom.info!aioe.org!news.mb-net.net!open-news-network.org!.POSTED!not-for-mail From: Thomas Rachel 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: References: <5002a1f9$0$29995$c3e8da3$5496439d@news.astraweb.com> <50037eab$0$29995$c3e8da3$5496439d@news.astraweb.com> <50047A84.6020208@gmail.com> <5004b543$0$29978$c3e8da3$5496439d@news.astraweb.com> <5004ec84$0$11116$c3e8da3@news.astraweb.com> <50050f70$0$30002$c3e8da3$5496439d@news.astraweb.com> <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 Am 08.02.2013 07:29 schrieb Rick Johnson: > Consider this: > > if connect("my:db") as db: > > > 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")): Is not very intuitive, however, but does its job. Thomas