Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!usenet-fr.net!nerim.net!novso.com!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'definitions': 0.07; 'purpose.': 0.07; 'definition,': 0.09; 'expectation': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'inherited': 0.09; 'message-id:@stoneleaf.us': 0.09; 'received:184.172': 0.09; 'received:gator410.hostgator.com': 0.09; 'subclasses': 0.09; '~ethan~': 0.09; 'ignore': 0.13; '10:05': 0.16; 'hierarchy': 0.16; 'traverse': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'feb': 0.19; 'code.': 0.20; 'ones.': 0.22; 'work,': 0.22; 'errors': 0.23; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'class': 0.29; 'classes': 0.30; 'call.': 0.30; 'impression': 0.33; 'to:addr:python-list': 0.33; 'requiring': 0.35; 'subject:?': 0.35; 'something': 0.35; 'method': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'option': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'enable': 0.60; 'real': 0.61; 'first': 0.61; 'production': 0.63; 'respect': 0.63; 'choose': 0.65; 'received:67.18': 0.65; 'special': 0.73; 'power': 0.74; '2013': 0.84; 'original.': 0.84; 'subject:any': 0.84; 'to:name:python': 0.84; 'contracts': 0.91; 'serious': 0.98 Date: Thu, 14 Feb 2013 10:33:14 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Python Subject: Re: any chance for contracts and invariants in Python? References: <70c4a8a5-0e8d-4e5c-b0cd-e4ccd90c5cb3@googlegroups.com> <511D18C8.5040404@phihag.de> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator410.hostgator.com X-AntiAbuse: Original Domain - python.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - stoneleaf.us X-BWhitelist: yes X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([173.12.184.235]) [173.12.184.235]:40218 X-Source-Auth: ethan+stoneleaf.us X-Email-Count: 1 X-Source-Cap: dG9idWs7dG9idWs7Z2F0b3I0MTAuaG9zdGdhdG9yLmNvbQ== 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: 28 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1360867351 news.xs4all.nl 6962 [2001:888:2000:d::a6]:58989 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:38876 On 02/14/2013 10:05 AM, Ian Kelly wrote: > On Thu, Feb 14, 2013 at 10:03 AM, Philipp Hagemeister wrote: >> So any implementation has to choose one of the following: >> >> 1. Ignore invariants and postconditions of inherited classes - defeats >> the purpose. >> 2. Only respect definitions in classes and methods in the original >> definition, which would be unpythonic >> 3. Only respect the "original" definitions, for some value of original. >> Simarily, this would break monkey patching. >> 4. Update all subclasses whenever something changes. >> 5. Traverse the entire class hierarchy for every method call. >> >> Which option should be picked? > > #5, with the expectation that like assertions the entire machinery > would be turned off when the -O flag is passed, or perhaps even > requiring a special flag to enable in the first place. Contracts and > invariants would only be used in development work, not in production > code. I was under the impression that the real power of contracts was when they are /not/ turned off -- the errors we don't catch in development are the serious ones. ;) -- ~Ethan~