Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Python': 0.06; 'suppose': 0.07; 'string': 0.09; 'lawrence': 0.09; 'logic': 0.09; 'parsed': 0.09; 'skip:/ 10': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; 'jan': 0.12; 'does,': 0.16; 'formula': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'grounds': 0.16; 'infinitely': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'all,': 0.19; 'file,': 0.19; 'pieces': 0.19; 'examples': 0.20; 'code,': 0.22; 'putting': 0.22; 'rules': 0.22; 'cc:addr:python.org': 0.22; 'config': 0.24; 'instance,': 0.24; 'of.': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'xml': 0.29; 'change,': 0.30; 'moved': 0.30; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'piece': 0.31; 'routine': 0.31; 'file': 0.32; 'text': 0.33; 'worked': 0.33; 'charge': 0.33; "i'd": 0.34; 'something': 0.35; 'more,': 0.35; 'one,': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'done': 0.36; "didn't": 0.36; 'should': 0.36; 'being': 0.38; 'files': 0.38; 'pm,': 0.38; 'anything': 0.39; 'simply': 0.61; 'times': 0.62; "you'll": 0.62; 'more': 0.64; 'afraid': 0.65; 'worth': 0.66; 'between': 0.67; '26,': 0.68; 'business': 0.70; 'hoping': 0.75; 'other.': 0.75; 'compiles': 0.84; 'fourth': 0.84; 'hardly': 0.84; 'silver': 0.84; 'edition': 0.86; 'to:none': 0.92; 'from.': 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=Bdymn4BL9Doc3dK6MMZU9sP3yHU4ooTfRobi6tMNKoE=; b=0IVI68pn8tyN5ekYdUDrBBo2cQobODpYjU6fx/uT7J0k9XjEIyYMHAFa0fEBBZeESZ 7Db7W34icPpX6xM1RzndQXwI7FH8//TNhmycaCeqS7bWRVtObc0enOEMqe7oLeHOnmlx A/Fy3bUEGWwGILihPJBz05nJj041F8lKZfQc4uEIFd7SI0W5kg+KPXm/RzxRTJaEE0Nu r1GvXfEZnHBx5jovHgUnUroOmJtQChg/o5u9nP4ACtdNxSN0/jCWLrnTrQsRgTFQkwxM CcW+o1N+u97V8pA5kydVAeyBFsnxa4BV/hOMQvPV3AabzOj7EH5RoDxAAEi/AE3SDywB ZX5Q== MIME-Version: 1.0 X-Received: by 10.66.27.72 with SMTP id r8mr22921333pag.62.1390709175826; Sat, 25 Jan 2014 20:06:15 -0800 (PST) In-Reply-To: References: <8fde6d34-47c5-49a1-a6d0-9ffe3df2d401@googlegroups.com> <52e473fc$0$29999$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 26 Jan 2014 15:06:15 +1100 Subject: Re: Python declarative 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390709179 news.xs4all.nl 2933 [2001:888:2000:d::a6]:39369 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64761 On Sun, Jan 26, 2014 at 1:45 PM, Mark Lawrence wrote: > If I worked as a consultant I'd much prefer the XML version as I'd be able > to charge much more on the grounds that I'd done much more, hoping that the > people paying didn't bother with design reviews or the like :) And that's very true. If someone wants something infinitely customizeable, the best solution might be an empty file with a shebang at the top - but that's hardly something you can charge oodles for. This is where soft-coding comes from. http://thedailywtf.com/Articles/Soft_Coding.aspx The business logic examples given there are best served by hard code. Suppose you need to calculate this-value plus that-value times other-value; is there any difference between writing that in Python (ugh, that's hard code!) and putting the formula in a config file, where it'll get parsed and evaluated (oh, that's a config file, that's fine)? As you'll see in my other post, there's a formula evaluator routine there; it takes a string of code and compiles it: (wealth_plat*1000+wealth_gold*100+wealth_silver*10+wealth_copper)/100 It's straight code, and it's embedded. If ever the rules change, I can edit the code. For instance, here's the D&D Fourth Edition version of that: (wealth_plat*10000+wealth_gold*100+wealth_silver*10+wealth_copper)/100 Should the value of a platinum coin be moved out into a config file? Maybe. MAYBE. Should the value of a silver piece be? Definitely not! There's no use-case for silver pieces being worth anything other than ten copper. If and when there is one, the code can simply be edited. There is no value in soft-coding this formula. Code isn't something to be afraid of. It's just text files like any other. After all, Python code is a config file for /usr/bin/python, so if you want to change what Python does, just edit its config file! ChrisA