Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!newsfeed.eweka.nl!eweka.nl!feeder3.eweka.nl!newsfeed.xs4all.nl!newsfeed6.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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; '"if': 0.04; 'sure.': 0.05; 'warnings': 0.05; 'compiler': 0.07; 'will,': 0.07; 'worst': 0.07; 'python': 0.09; '"="': 0.16; '(eg': 0.16; '-wall': 0.16; 'compilers': 0.16; 'covers.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'pythonic': 0.16; 'yell': 0.16; 'operator': 0.16; 'mon,': 0.16; 'c++': 0.19; 'wrote:': 0.20; 'header:In-Reply-To:1': 0.21; 'received:209.85.210.174': 0.21; 'received:mail-iy0-f174.google.com': 0.21; 'accidentally': 0.23; 'gcc': 0.23; 'yeah,': 0.23; 'structure': 0.23; 'message- id:@mail.gmail.com': 0.23; 'tim': 0.24; "doesn't": 0.24; 'fact': 0.25; "i'm": 0.27; "i've": 0.27; 'second': 0.27; 'comparing': 0.29; 'things,': 0.29; 'character.': 0.30; 'omitted': 0.30; 'solved': 0.30; 'am,': 0.31; 'problem': 0.31; 'times,': 0.32; 'to:addr:python-list': 0.32; 'quite': 0.32; 'does': 0.33; 'received:209.85': 0.34; 'received:google.com': 0.34; 'programming,': 0.34; 'surprised': 0.35; 'test': 0.35; 'something': 0.35; 'really': 0.35; 'received:209': 0.36; 'sometimes': 0.36; 'someone': 0.36; 'but': 0.36; 'clear': 0.36; 'problems': 0.38; 'connection': 0.38; 'object': 0.38; 'where': 0.39; '(with': 0.39; 'to:addr:python.org': 0.39; 'subject:, ': 0.60; 'your': 0.61; 'matter': 0.61; 'alert': 0.64; 'love': 0.64; '26,': 0.67; 'overload': 0.67; 'mar': 0.69; 'series': 0.69; 'acts': 0.73; 'numerous': 0.73; '2012': 0.74; '12:48': 0.84; 'sort.': 0.84; 'technique.': 0.84; 'ways;': 0.84; '"best': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=I7Sse+FKGiC838i0K2WCAz2qIvSsJKPcQMFgZVMnPnQ=; b=YorHwlHAFVHrzAX61TGT6d4Y+Yk17UGL+ApqfGOm7burO3INCFnO6TdBZO7XwQvNjX ICmuw7bkH0HuF+shY2vEU6lbHsnZWB3KGVkuCMo4Rt7xmIS4UMeTF76K+eNsmb1gsoNd rYL4At1oKv/ynJ2r5Dw1eHEWHZ6MYmxKga95Jk0CIEn6v3H+zcs0P/n17Zp/TQSUqUid rQhsRWJEyClQ+KANGaC4HShQAlpmGn2jDwcIEeSZdKeA3yRLctfyPADe+ewOg0tCOMTV 0BY5unh6WZR9TEo5BHRJfSooGV0zPq+628hsmtRuG9SUKXKc3bAefnBgpaDNYKTr4hdH +W9Q== MIME-Version: 1.0 In-Reply-To: <4F6F222F.7050406@tim.thechases.com> References: <4f6d0060$0$6634$9b4e6d93@newsspool2.arcor-online.net> <4f6f0d24$0$6561$9b4e6d93@newsspool4.arcor-online.net> <4F6F1792.1060709@tim.thechases.com> <4F6F222F.7050406@tim.thechases.com> Date: Mon, 26 Mar 2012 01:11:48 +1100 Subject: Re: Documentation, assignment in expression. From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1332684711 news.xs4all.nl 6927 [2001:888:2000:d::a6]:50651 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:22139 On Mon, Mar 26, 2012 at 12:48 AM, Tim Chase wrote: > Yeah, it has the same structure internally, but I'm somewhat surprised th= at > the DB connection object doesn't have an __iter__() that does something l= ike > this automatically under the covers. Sure. That's definitely the truly Pythonic technique. If I build a C++ object that acts like an array, it's going to overload the [] dereference operator - and if I build a Python object that returns a series of things, it's going to be an iterable. > In my past years of C programming, I've accidentally omitted the second "= =3D" > in a comparison test numerous times, requiring me to track down the missi= ng > character. =A0When I finally catch it, it's obvious what the problem is, = but > I've come to love having Python yell at me contextually. This is where compiler warnings come in handy. GCC will, in what I told someone was "Perls of Wisdom mode" (with the -Wall option - yes, it is that bad a pun), recommend clarification of the worst offenders of this sort. And in the common case where you're comparing against a constant, quite a few compilers will alert you to the fact that your condition is always true/always false (eg "if (x=3D3) ;"). Many problems can be solved in multiple ways; sometimes there's a clear "best way", other times it really doesn't matter matter matter matter matter. ChrisA