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


Groups > comp.lang.python > #107528

Re: How much sanity checking is required for function inputs?

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Christopher Reimer <christopher_reimer@icloud.com>
Newsgroups comp.lang.python
Subject Re: How much sanity checking is required for function inputs?
Date Sat, 23 Apr 2016 19:03:03 -0700
Lines 26
Message-ID <mailman.21.1461463390.32212.python-list@python.org> (permalink)
References <5713E52D.3060407@icloud.com> <1461131475.4042173.584042297.03DAB00E@webmail.messagingengine.com> <57171D23.40709@stoneleaf.us> <1461133057.4046578.584060569.2DD34821@webmail.messagingengine.com> <57185E88.30201@yahoo.com> <57197FC3.4030701@icloud.com> <57198827.1020608@stoneleaf.us> <5719964E.2050400@icloud.com> <CAG93HwHmQUABxKwDdWEbdTJ0gDQVcUW52uqjGLC6j8b53MPh4g@mail.gmail.com> <571C2957.7060508@icloud.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Trace news.uni-berlin.de DGnikrRHPb+N3umjNZvEMAJ0BdUwtjpCuJK76jfkpz3A==
Return-Path <christopher_reimer@icloud.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.150
X-Spam-Level *
X-Spam-Evidence '*H*': 0.70; '*S*': 0.00; 'sanity': 0.07; 'subject:How': 0.09; 'backwards': 0.09; 'instantiated': 0.09; 'prevents': 0.09; 'stored': 0.10; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:required': 0.16; 'worst': 0.16; 'wrote:': 0.16; 'board.': 0.18; 'load': 0.20; 'java': 0.22; '(or': 0.23; "haven't": 0.24; 'header:User-Agent:1': 0.26; '(which': 0.26; 'chris': 0.26; 'received:17': 0.27; 'then.': 0.27; 'pickle': 0.29; 'url:wikipedia': 0.29; "i'm": 0.30; 'board': 0.30; 'classes': 0.30; 'url:wiki': 0.30; 'code': 0.30; 'another': 0.32; 'received:10.0.0': 0.32; 'impression': 0.33; 'rule': 0.33; "i'll": 0.33; 'case,': 0.34; 'received:10.0': 0.34; 'add': 0.34; 'confirmed': 0.35; 'something': 0.35; 'but': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'being': 0.37; 'thought': 0.37; 'starting': 0.37; 'thank': 0.38; 'means': 0.39; 'url:en': 0.39; 'does': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'still': 0.40; 'header:MIME-version:1': 0.60; 'ever': 0.60; 'save': 0.60; 'your': 0.60; 'suitable': 0.61; 'side': 0.62; 'charset:windows-1252': 0.62; 'positions': 0.64; 'promotion': 0.65; 'state,': 0.66; 'saving': 0.70; 'state.': 0.72; 'won': 0.76; 'cheating': 0.84; 'habits.': 0.84; 'header:In-reply-to:1': 0.84; 'move.': 0.84; 'outrageously': 0.84; 'ethan': 0.91; 'played': 0.91; 'promotion,': 0.91; 'subject:much': 0.91
X-Proofpoint-Virus-Version vendor=fsecure engine=2.50.10432:,, definitions=2016-04-24_02:,, signatures=0
X-Proofpoint-Spam-Details rule=notspam policy=default score=0 spamscore=0 clxscore=1015 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1510270003 definitions=main-1604240032
User-Agent Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2
In-reply-to <CAG93HwHmQUABxKwDdWEbdTJ0gDQVcUW52uqjGLC6j8b53MPh4g@mail.gmail.com>
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=4d515a; t=1461463381; bh=sPwpL4kTvQK+SQbpd9lYBdd3gRTFnnj/vrGfxYgKCX8=; h=Subject:To:From:Message-id:Date:MIME-version:Content-type; b=JxqCfMBubrnLmAF0/U1nwNirUbOeSMTl67BAxEERBQ6q9FvszyfugnMGXiGn3UPKa H/toxomZ14E21/BgH9jK+CnveGgQjJ2Kx1cZ2U9XmVsoDUS13cSAtydmQot2AFKueU Ky3p7JFRiu52ea/8D0U/JCPzyBNi9pdacwMi1UI+hpeB9M/tYr/pLIafmbGsm3/ANu Suhlqwg/O9ZojR0QWiYOnwu58hJwvBP22yCccfhOynAPqxDNvXoOoWHiWjmrm4916i T+VkUkyx4vWWxCrt9/sCmMRWRkSSxhAYH+GkhRhU+muOgTr4gPhnxAc0Fp1P6PxGlT z8VGce3Gdzclg==
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.22
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <571C2957.7060508@icloud.com>
X-Mailman-Original-References <5713E52D.3060407@icloud.com> <1461131475.4042173.584042297.03DAB00E@webmail.messagingengine.com> <57171D23.40709@stoneleaf.us> <1461133057.4046578.584060569.2DD34821@webmail.messagingengine.com> <57185E88.30201@yahoo.com> <57197FC3.4030701@icloud.com> <57198827.1020608@stoneleaf.us> <5719964E.2050400@icloud.com> <CAG93HwHmQUABxKwDdWEbdTJ0gDQVcUW52uqjGLC6j8b53MPh4g@mail.gmail.com>
Xref csiph.com comp.lang.python:107528

Show key headers only | View raw


On 4/23/2016 2:33 PM, Matt Wheeler wrote:
> This is still backwards to me. It prevents your classes from being
> suitable for restoring a stored game state, not just custom starting
> positions (which I think is what Ethan means by custom setups).

I haven't thought that far about saving the game state. I'm under the 
impression that pickle (or something else) would save and load the 
instantiated object of each piece. If that's not the case, I'll change 
the code then.

The sanity check does have an exemption for pawn promotion, where a pawn 
reaching the other side of the board can be promoted to another piece 
(typically a queen). I played Sargon II chess on the Commodore 64 for 
five years as a teenager. The worst game I ever won was when the 
computer had nine queens on the board. I thought the computer was 
cheating outrageously but a chess rule book confirmed that promotion was 
a legit move.

https://en.wikipedia.org/wiki/Promotion_(chess)

If I need to add an exemption to custom plays, I'll add it then. Right 
now I'm cleaning up the existing code from all the bad Java habits.

Thank you,

Chris R.

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


Thread

Re: How much sanity checking is required for function inputs? Christopher Reimer <christopher_reimer@icloud.com> - 2016-04-23 19:03 -0700
  Re: How much sanity checking is required for function inputs? Steven D'Aprano <steve@pearwood.info> - 2016-04-24 15:38 +1000
    Re: How much sanity checking is required for function inputs? Marko Rauhamaa <marko@pacujo.net> - 2016-04-24 08:56 +0300

csiph-web