Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #38874

Re: any chance for contracts and invariants in Python?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.007
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'decorator': 0.07; 'definitions': 0.07; 'purpose.': 0.07; 'definition,': 0.09; 'expectation': 0.09; 'inherited': 0.09; 'subclasses': 0.09; 'wraps': 0.09; 'ignore': 0.13; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'hierarchy': 0.16; 'message- id:@mrabarnett.plus.com': 0.16; 'traverse': 0.16; 'wrote:': 0.17; 'thu,': 0.17; 'creates': 0.18; 'feb': 0.19; 'code.': 0.20; 'work,': 0.22; 'header:In-Reply-To:1': 0.25; 'header:User- Agent:1': 0.26; 'am,': 0.27; 'functions.': 0.27; 'class': 0.29; 'maybe': 0.29; 'classes': 0.30; 'call.': 0.30; 'to:addr:python- list': 0.33; 'requiring': 0.35; 'subject:?': 0.35; 'something': 0.35; 'method': 0.36; 'should': 0.36; 'option': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'received:192.168': 0.40; 'enable': 0.60; 'first': 0.61; 'production': 0.63; 'respect': 0.63; 'choose': 0.65; 'header :Reply-To:1': 0.68; 'reply-to:no real name:2**0': 0.72; 'special': 0.73; '2013': 0.84; 'original.': 0.84; 'reply-to:addr:python.org': 0.84; 'subject:any': 0.84; 'contracts': 0.91
X-CM-Score 0.00
X-CNFS-Analysis v=2.0 cv=XeZXOvF5 c=1 sm=1 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=Tv4_tr9OjFAA:10 a=7k_ktU75BzwA:10 a=ihvODaAuJD4A:10 a=OUOv7kDek9cA:10 a=8nJEP1OIZ-IA:10 a=EBOSESyhAAAA:8 a=8AHkEIZyAAAA:8 a=XFdiRGhafKMA:10 a=FjnWQqUj12Qi0WWZy08A:9 a=wPNLvfGTeEIA:10 a=T6rte8_hsbQA:10 a=0nF1XD0wxitMEM03M9B4ZQ==:117
X-AUTH mrabarnett:2500
Date Thu, 14 Feb 2013 18:18:53 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130107 Thunderbird/17.0.2
MIME-Version 1.0
To python-list@python.org
Subject Re: any chance for contracts and invariants in Python?
References <70c4a8a5-0e8d-4e5c-b0cd-e4ccd90c5cb3@googlegroups.com> <511D18C8.5040404@phihag.de> <CALwzidnDuqCMOdpmM2doD9EkL6JyOvDsqBZ+xzzMb-pXgD+Hng@mail.gmail.com>
In-Reply-To <CALwzidnDuqCMOdpmM2doD9EkL6JyOvDsqBZ+xzzMb-pXgD+Hng@mail.gmail.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1774.1360865934.2939.python-list@python.org> (permalink)
Lines 24
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1360865934 news.xs4all.nl 6900 [2001:888:2000:d::a6]:48304
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:38874

Show key headers only | View raw


On 2013-02-14 18:05, Ian Kelly wrote:
> On Thu, Feb 14, 2013 at 10:03 AM, Philipp Hagemeister <phihag@phihag.de> 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.
>
Maybe what it needs is a decorator that parses the docstrings, creates
functions to do the checks, and then wraps them around the functions.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

any chance for contracts and invariants in Python? mrkafk@gmail.com - 2013-02-14 03:42 -0800
  Re: any chance for contracts and invariants in Python? Philipp Hagemeister <phihag@phihag.de> - 2013-02-14 18:03 +0100
  Re: any chance for contracts and invariants in Python? Ian Kelly <ian.g.kelly@gmail.com> - 2013-02-14 11:05 -0700
  Re: any chance for contracts and invariants in Python? MRAB <python@mrabarnett.plus.com> - 2013-02-14 18:18 +0000
  Re: any chance for contracts and invariants in Python? Ethan Furman <ethan@stoneleaf.us> - 2013-02-14 10:33 -0800
  Re: any chance for contracts and invariants in Python? Mark Janssen <dreamingforward@gmail.com> - 2013-02-14 18:33 -0800

csiph-web