Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #4801
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <chris@rebertia.com> |
| 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; 'received:209.85.213.46': 0.07; 'received:mail-yw0-f46.google.com': 0.07; 'empty,': 0.09; 'imo.': 0.09; 'pm,': 0.11; 'wrote:': 0.14; '11:36': 0.16; 'pythonic': 0.16; 'cc:2**0': 0.20; 'cheers,': 0.20; 'subject:list': 0.22; 'header:In-Reply-To:1': 0.22; 'cc:addr :python-list': 0.22; 'thu,': 0.22; 'received:209.85.213': 0.23; 'way?': 0.23; 'chris': 0.27; 'message-id:@mail.gmail.com': 0.28; 'hi,': 0.29; 'list': 0.30; 'cc:addr:python.org': 0.31; '...': 0.32; 'option': 0.33; 'received:209.85': 0.37; 'received:google.com': 0.38; 'received:209': 0.39; 'header:Received:5': 0.40; '2011': 0.62 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=rebertia.com; s=google; h=domainkey-signature:mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=5CYXuFBuCsGBs74+a0KBMFzOjwYM8dc7v+U3Omg58j4=; b=KuLD1H6BFfmvAuH/d6q6DqfdnbCfQfcaJjyE4YQFJjgCWFYkWdzfc1S82X1pMWq5gy NJxIei+eTffZDn2mSq1wFZDeIYuCVl/wuvsuFg9rsFGl7aZ8Zy08OZremBsDOPX+joTR X0erFrcyKlBOFz83LGjoFcl4ULMp66jhztufY= |
| DomainKey-Signature | a=rsa-sha1; c=nofws; d=rebertia.com; s=google; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; b=IZQDO81ZWEv9lr5bpaIitRUqle0eIOvyZGks1ETaa/ioJSFpSQAPMOnMViEh1DtrVL 9JLppYkKe0PDPnkCh0R2DD0adY2bpT+KzLuyJU/52d07iyVSv7t3qYtAOtlJujIu/48Z y6s27sD8fPWAAFV2qkOkwtqXEn5KA+1d6XlIw= |
| MIME-Version | 1.0 |
| Sender | chris@rebertia.com |
| In-Reply-To | <BANLkTikF18n2dBU6hhFngcAPkE2ZpErVAw@mail.gmail.com> |
| References | <BANLkTikF18n2dBU6hhFngcAPkE2ZpErVAw@mail.gmail.com> |
| Date | Fri, 6 May 2011 00:08:24 -0700 |
| X-Google-Sender-Auth | aZVbkDsakTO2bqsL8hEGeXfO-YE |
| Subject | Re: checking if a list is empty |
| From | Chris Rebert <clp2@rebertia.com> |
| To | Jabba Laci <jabba.laci@gmail.com> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | Python mailing list <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1228.1304665707.9059.python-list@python.org> (permalink) |
| Lines | 21 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1304665707 news.xs4all.nl 41117 [::ffff:82.94.164.166]:37270 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:4801 |
Show key headers only | View raw
On Thu, May 5, 2011 at 11:36 PM, Jabba Laci <jabba.laci@gmail.com> wrote:
> Hi,
>
> If I want to check if a list is empty, which is the more pythonic way?
Option (2), IMO.
> li = []
>
> (1) if len(li) == 0:
> ...
FYI, also equivalent:
if not len(li):
...
> or
> (2) if not li:
Cheers,
Chris
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: checking if a list is empty Chris Rebert <clp2@rebertia.com> - 2011-05-06 00:08 -0700
csiph-web