Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: Christopher Reimer Newsgroups: comp.lang.python Subject: Re: How much sanity checking is required for function inputs? Date: Sat, 23 Apr 2016 18:30:11 -0700 Lines: 26 Message-ID: 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> <1461291613.433097.586174185.01BB7E37@webmail.messagingengine.com> <57199BA5.4000703@icloud.com> <1461302724.477236.586265777.181ACCA0@webmail.messagingengine.com> <571C21A3.5090507@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 4UHF3DW1U3IdLBbch9yXjAEbm0+CV8f1NTyb7770h0yQ== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.033 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'properly.': 0.07; 'subject:How': 0.09; '16)': 0.09; 'occurrences': 0.09; 'python': 0.10; 'constants': 0.16; 'coordinates': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:required': 0.16; 'wrote:': 0.16; 'removed.': 0.18; 'project,': 0.18; 'variable': 0.18; 'together.': 0.20; 'first,': 0.20; 'not,': 0.22; 'constant': 0.22; 'stephen': 0.22; 'code,': 0.23; 'seems': 0.23; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'module.': 0.27; 'received:17': 0.27; 'said,': 0.27; 'correct': 0.28; 'dictionary': 0.29; "i'm": 0.30; 'code': 0.30; 'putting': 0.30; 'probably': 0.31; 'received:10.0.0': 0.32; 'getting': 0.33; 'changed': 0.33; 'class': 0.33; 'common': 0.33; 'received:10.0': 0.34; 'replace': 0.35; 'instead': 0.36; 'to:addr :python-list': 0.36; 'subject:?': 0.36; 'pm,': 0.36; 'subject:: ': 0.37; 'received:10': 0.37; 'two': 0.37; 'being': 0.37; 'list.': 0.37; 'thank': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'header:MIME-version:1': 0.60; 'your': 0.60; 'share': 0.61; 'black': 0.61; 'further': 0.62; 'here.': 0.62; 'research': 0.62; 'charset:windows-1252': 0.62; 'different': 0.63; 'positions': 0.64; 'wanting': 0.66; 'color': 0.67; 'configparser': 0.84; 'header:In-reply-to:1': 0.84; '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-1604240023 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 In-reply-to: <1461302724.477236.586265777.181ACCA0@webmail.messagingengine.com> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=4d515a; t=1461461410; bh=stLuOIo19nHDFpZ6fJSP3ferGSQqfKOcvwCgeIsUlrM=; h=Subject:To:From:Message-id:Date:MIME-version:Content-type; b=BGhHW4Cp7rfz7xemGg6L7MR+hrxoGQjW+2UvWhXcXKJNC3lFso4OfMomrtrG7N3Uo r7Q9TJWpIg4hQYUGutiqvbyZkMnCl1eTVyRQ+qzJhVnKoEjMhXW+uwpn6RTUtTRJk1 mTbh5CMek+XrLmeuvykxy1EVt2TT4SRd44CeH+kAGv/sMSaEB1S4IBwfufcatcT7YD qt/zgoflYnp/1GYLJGKfYZvrRK1bHiytMwtGvjwNcBaCyzUiTGN0/N80Bzkib3AlCT PWK5LmwlUG9d6btEa6DTt682MHCtqe3yiciWrRCbMdDgcFcLJdxFeSf2bGGNCd8Fr4 hX1LVSJBLvs0w== X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <571C21A3.5090507@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> <1461291613.433097.586174185.01BB7E37@webmail.messagingengine.com> <57199BA5.4000703@icloud.com> <1461302724.477236.586265777.181ACCA0@webmail.messagingengine.com> Xref: csiph.com comp.lang.python:107524 On 4/21/2016 10:25 PM, Stephen Hansen wrote: > > Why not, 'color in ("black", "white")'? Checkers seems popular around here. What if I want to change "white" to "red," as red and black is a common color scheme for checkers. Do I change a single constant variable or replace all the occurrences in the files? Some of these constants are shortcuts. Instead of writing slice(0, 16) or slice(48, 64), and getting the two confused, I write const['board_bottom'] or const['board_top'], respectively, when I want to pull the correct set of positions from coordinates list. > That said, if you're wanting to share constants across different parts > of your code, use a module. I did that at first, made it into a dictionary class and added ConfigParser to the mix. I had a lot of fun putting that one together. However, as I refactor my code further as I learn new things, it will probably get changed or removed. Being a research project, I'm willing to dive into every rabbit hole that I come across to learn Python properly. Thank you, Chris R.