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


Groups > comp.lang.python > #64761

Re: Python declarative

References (5 earlier) <lbtnft$6gf$1@ger.gmane.org> <CAPTjJmpi-kvJAVs2gK+nH5n6q3REkJaKR=CZeRfzUgDk8_VLGw@mail.gmail.com> <mailman.5968.1390634333.18130.python-list@python.org> <52e473fc$0$29999$c3e8da3$5496439d@news.astraweb.com> <lc1st6$c73$1@ger.gmane.org>
Date 2014-01-26 15:06 +1100
Subject Re: Python declarative
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.5987.1390709179.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Jan 26, 2014 at 1:45 PM, Mark Lawrence <breamoreboy@yahoo.co.uk> 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

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


Thread

Python declarative Sergio Tortosa Benedito <sertorbe@gmail.com> - 2014-01-15 18:02 +0100
  Re: Python declarative Francesco Bochicchio <bieffe62@gmail.com> - 2014-01-17 06:22 -0800
    Re: Python declarative Francesco Bochicchio <bieffe62@gmail.com> - 2014-01-19 23:25 -0800
  Re: Python declarative sertorbe@gmail.com - 2014-01-17 06:47 -0800
    Re: Python declarative Tim Roberts <timr@probo.com> - 2014-01-18 13:13 -0800
  Re: Python declarative sertorbe@gmail.com - 2014-01-19 02:27 -0800
  Re: Python declarative sertorbe@gmail.com - 2014-01-22 12:38 -0800
  Re: Python declarative Asaf Las <roegltd@gmail.com> - 2014-01-22 13:16 -0800
    Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-23 13:29 +1100
    Re: Python declarative Terry Reedy <tjreedy@udel.edu> - 2014-01-22 23:08 -0500
    Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-24 11:21 +0200
      Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-24 01:53 -0800
        Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-24 15:06 +0200
    Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-24 22:18 +1100
    Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-24 14:49 +0200
    Re: Python declarative Burak Arslan <burak.arslan@arskom.com.tr> - 2014-01-24 15:40 +0200
    Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-25 00:55 +1100
    Re: Python declarative Matěj Cepl <mcepl@redhat.com> - 2014-01-24 17:28 +0100
    Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-25 03:33 +1100
      Re: Python declarative sertorbe@gmail.com - 2014-01-24 10:51 -0800
    Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-25 09:18 +0200
      Re: Python declarative Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-26 02:33 +0000
        Re: Python declarative Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-01-26 02:45 +0000
          Re: Python declarative Asaf Las <roegltd@gmail.com> - 2014-02-02 18:17 -0800
        Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-26 14:38 +1100
        Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-26 15:06 +1100
          Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-25 20:47 -0800
            Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-26 16:23 +1100
              Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-26 00:05 -0800
                Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-26 11:12 +0200
                Re: Python declarative Rustom Mody <rustompmody@gmail.com> - 2014-01-26 06:36 -0800
          Re: Python declarative Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-26 12:05 +0000
        Re: Python declarative "Frank Millman" <frank@chagford.com> - 2014-01-26 08:03 +0200
          Re: Python declarative Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-01-26 12:21 +0000
    Re: Python declarative Chris Angelico <rosuav@gmail.com> - 2014-01-25 18:33 +1100
    Re: Python declarative matej@ceplovi.cz (Matěj Cepl) - 2014-01-25 12:23 +0100
  Re: Python declarative Asaf Las <roegltd@gmail.com> - 2014-01-24 04:04 -0800

csiph-web