Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'infinite': 0.07; 'python': 0.08; '"current': 0.09; '(line': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'stating': 0.09; 'url:faq': 0.09; 'bieber': 0.16; 'declaimed': 0.16; 'email addr:ix.netcom.com': 0.16; 'email name:wlfraed': 0.16; 'expression,': 0.16; 'from:addr:ix.netcom.com': 0.16; 'from:addr:wlfraed': 0.16; 'from:name:dennis lee bieber': 0.16; 'ideas?': 0.16; 'in...': 0.16; 'iterator': 0.16; 'received:wlfraed': 0.16; 'url:netcom': 0.16; 'url:wlfraed': 0.16; 'version"': 0.16; 'wulfraed': 0.16; 'syntax': 0.16; 'this:': 0.16; 'meant': 0.17; 'example.': 0.18; 'written': 0.19; 'url:home': 0.21; 'input': 0.22; '+0100,': 0.23; 'loop,': 0.23; 'stuff': 0.26; 'separate': 0.28; 'explicitly': 0.29; 'example': 0.29; 'line:': 0.30; 'new.': 0.30; 'least': 0.30; 'equivalent': 0.31; 'version': 0.32; 'break': 0.32; 'objects': 0.32; 'fri,': 0.34; 'file': 0.34; 'header:X-Complaints-To:1': 0.34; 'lee': 0.34; 'hi,': 0.34; 'advocate': 0.34; 'assignment': 0.34; 'emphasis': 0.34; 'to:addr:python-list': 0.35; '...': 0.35; 'something': 0.35; '(for': 0.35; 'url:python': 0.35; 'received:org': 0.36; 'example,': 0.37; 'reasons': 0.37; 'but': 0.37; 'charset:us-ascii': 0.37; 'using': 0.37; 'received:76': 0.37; 'some': 0.38; 'think': 0.38; 'url:org': 0.39; 'might': 0.40; 'to:addr:python.org': 0.40; 'your': 0.61; 'design': 0.61; 'kind': 0.62; 'ever': 0.64; '"for': 0.67; 'dennis': 0.73; 'url:design': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Dennis Lee Bieber Subject: Re: Documentation, assignment in expression. Date: Fri, 23 Mar 2012 21:09:16 -0400 Organization: > Bestiaria Support Staff < References: <4f6d0060$0$6634$9b4e6d93@newsspool2.arcor-online.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: adsl-76-253-99-231.dsl.klmzmi.sbcglobal.net X-Newsreader: Forte Agent 3.3/32.846 X-No-Archive: YES 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: 47 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332551363 news.xs4all.nl 6949 [2001:888:2000:d::a6]:48395 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22107 On Fri, 23 Mar 2012 23:59:44 +0100, Alexander Blinne declaimed the following in gmane.comp.python.general: > Hi, > > I think this section of the docs needs some kind of rewrite: > > > > While it is great to discuss the reasons for not allowing an assignment > in an expression, I feel that the given example is some kind of > outdated. The last sentence "For example, in the current version of > Python file objects support the iterator protocol, so you can now write > simply (for line in file:)" makes me think that this section was written > while that syntax was still new. No one I know would ever write > something like this: > > > while True: > > line = f.readline() > > if not line: > > break > > ... # do something with line > > I think at least we need a new example. Any ideas? > But remember -- this is a section on why no "assignment in expression"... That means for line in f: #do stuff is the counter to the equivalent C-style while (line = f.readline() ): #mixing C style with Python calls # do stuff The section is not meant to be an advocate for or against your true Python design using an infinite loop, and separate input line. The emphasis on "current version" might do with updating -- by explicitly stating when the iteration came in... -- Wulfraed Dennis Lee Bieber AF6VN wlfraed@ix.netcom.com HTTP://wlfraed.home.netcom.com/