Path: csiph.com!usenet.pasdenom.info!gegeweb.org!newsfeed.kamp.net!newsfeed.kamp.net!newsfeed.freenet.ag!news2.euro.net!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.005 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python': 0.09; 'data:': 0.09; '**kwargs)': 0.16; '**kwargs):': 0.16; '*args,': 0.16; '-tkc': 0.16; 'alexander': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'iterator': 0.16; 'message-id:@tim.thechases.com': 0.16; 'received:70.251': 0.16; 'received:dsl.rcsntx.swbell.net': 0.16; 'received:rcsntx.swbell.net': 0.16; 'received:swbell.net': 0.16; 'row': 0.16; 'cc:addr:python-list': 0.16; 'this:': 0.16; 'def': 0.16; 'example.': 0.19; 'wrote:': 0.20; 'header:In-Reply-To:1': 0.21; 'cc:no real name:2**0': 0.27; 'yield': 0.29; 'cc:2**0': 0.29; 'stuff': 0.29; 'granted,': 0.30; 'line:': 0.30; 'cc:addr:python.org': 0.30; 'example': 0.31; 'header:User- Agent:1': 0.32; 'break': 0.32; "isn't": 0.33; 'assignment': 0.35; 'doc': 0.35; 'something': 0.35; '...': 0.37; 'think': 0.38; 'issue': 0.38; 'data': 0.38; 'perhaps': 0.38; 'subject:, ': 0.60; 'your': 0.61; 'making': 0.62; 'received:50': 0.67; 'complaint': 0.84; 'received:50.22': 0.84; 'true:': 0.84 Date: Sun, 25 Mar 2012 08:03:14 -0500 From: Tim Chase User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.24) Gecko/20111120 Icedove/3.1.16 MIME-Version: 1.0 To: Alexander Blinne Subject: Re: Documentation, assignment in expression. References: <4f6d0060$0$6634$9b4e6d93@newsspool2.arcor-online.net> <4f6f0d24$0$6561$9b4e6d93@newsspool4.arcor-online.net> In-Reply-To: <4f6f0d24$0$6561$9b4e6d93@newsspool4.arcor-online.net> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - boston.accountservergroup.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tim.thechases.com X-Source: X-Source-Args: X-Source-Dir: Cc: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 54 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332680571 news.xs4all.nl 6953 [2001:888:2000:d::a6]:37335 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22136 On 03/25/12 07:18, Alexander Blinne wrote: > I am not sure I understand your argument. The doc section states that > > " [...] in Python you’re forced to write this: > > while True: > line = f.readline() > if not line: > break > ... # do something with line". > > That simply isn't true as one can simply write: > > for line in f: > #do stuff I think the complaint was backed by a bad example. Perhaps a DB example works better. With assignment allowed in an evaluation, you'd be able to write while data = conn.fetchmany(): for row in data: process(row) whereas you have to write while True: data = conn.fetchmany() if not data: break for row in data: process(row) Granted, this can be turned into an iterator with a yield, making the issue somewhat moot: def db_iter(conn, *args, **kwargs): while True: data = conn.fetchmany(rows, *args, **kwargs) if not data: break for row in data: yield row for row in db_iter(conn): proecss(row) -tkc