Path: csiph.com!usenet.pasdenom.info!news.albasani.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.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.060 X-Spam-Evidence: '*H*': 0.88; '*S*': 0.00; 'falls': 0.09; 'latter': 0.09; 'subject:module': 0.09; 'cc:addr:python-list': 0.11; "wouldn't": 0.14; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'oddly': 0.16; 'referencing': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'cc:addr:python.org': 0.22; 'either.': 0.24; "shouldn't": 0.24; 'subject:problem': 0.24; 'earlier': 0.24; 'cc:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'specifically': 0.29; 'message-id:@mail.gmail.com': 0.30; 'code': 0.31; '(maybe': 0.31; "d'aprano": 0.31; 'reflected': 0.31; 'steven': 0.31; 'though.': 0.31; 'comment': 0.34; 'could': 0.34; 'subject:with': 0.35; 'knows': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; '14,': 0.36; 'next': 0.36; 'method': 0.36; 'should': 0.36; 'half': 0.37; 'easily': 0.37; 'pm,': 0.38; 'called': 0.40; 'first': 0.61; 'between': 0.67; 'reads': 0.68; 'evening': 0.84; 'silently': 0.84; 'upset': 0.84; 'absolutely': 0.87; 'to:none': 0.92; 'imagine': 0.93; 'live.': 0.93 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:cc :content-type; bh=4yYkEWvrS2CztUNEyNIsx37+pDS/fmxHgMs9b7zmhjQ=; b=d+m9Edo5xiII/oE0y0yvtShwGQBo+Jta73mr+UW2j5u3L2BoHm0zAliAujZhP1Vn2Q IuOiUbt16eIGb+oRXWnpp7ISzJ/YNyVvGzMvNgHJnrKGiJ0501AVoLGZVR1V/zAAfNFZ 0jD17ZOdLdddzu6gAtgeQWNN1lWZlEalsdFcwyOEwPWW2AOJGNbjW8ANdGFUgQsoDd/l b2el5P4umtXbpGhoBwg+BaKcoFSzRNsL3Po+D4KfaSw84AvSgh1lVG5RB2RkCc9F4zIu kLyWO05edwoE31ZcG46EsrIDOdazBDDR4FDmM89FQ+kzDVlJuAVrv/6ID6dVSRW8n1mS ogMA== MIME-Version: 1.0 X-Received: by 10.58.160.134 with SMTP id xk6mr77780veb.64.1400073465237; Wed, 14 May 2014 06:17:45 -0700 (PDT) In-Reply-To: <53736acb$0$29977$c3e8da3$5496439d@news.astraweb.com> References: <5372b2ae$0$29977$c3e8da3$5496439d@news.astraweb.com> <53736acb$0$29977$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 14 May 2014 23:17:45 +1000 Subject: Re: Exception problem with module From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1400073467 news.xs4all.nl 2874 [2001:888:2000:d::a6]:50217 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71557 On Wed, May 14, 2014 at 11:08 PM, Steven D'Aprano wrote: > One should code as if the next person who reads your program is an easily > upset psychotic axe-murderer who knows where you live. You wouldn't > condone writing y = x.__add__(1) instead of y = x + 1, you shouldn't > condone writing module.__setattr__ directly either. Oddly enough, I was referencing that first half earlier this evening :) There's a difference between x.__add__(1) and x + 1, though. The latter might end up calling (1).__radd__(x), which (obviously) the first won't. I can imagine there might be some use-case where you specifically DON'T want the reflected method to be silently called (maybe for introspection or debugging??). But it falls under code smell, the sort of thing where you absolutely MUST have a comment - like where I have a call to set_foreground(bg), because that could so easily be an error, yet in this case isn't. ChrisA