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: 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: References: 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 To: Jabba Laci Content-Type: text/plain; charset=UTF-8 Cc: Python mailing list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 On Thu, May 5, 2011 at 11:36 PM, Jabba Laci 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