Splitting of string at an interval
Roy Smith
roy at panix.com
Mon Apr 8 09:21:56 EDT 2013
In article <mailman.263.1365390121.3114.python-list at python.org>,
Chris Angelico <rosuav at gmail.com> wrote:
> On Mon, Apr 8, 2013 at 7:48 AM, Steven D'Aprano
> <steve+comp.lang.python at pearwood.info> wrote:
> > Like every programming problem, the solution is to break it apart into
> > small, simple steps that even a computer can follow.
> > ...
>
> 5) Shortcut the whole thing, since the problem was underspecified, by
> using a literal.
>
> words = ["The Sun", "rises in", "in the", "east of", "our earth"]
>
> *dive for cover against rotten tomatoes*
Seems like the right solution to me.
For a while, I was rabidly(*) into TDD (Test Driven Development). The
cycle I was using was, "Write a specification of a behavior, write a
(failing) test for that behavior, then write the least possible amount
of code to make the test pass. Lather, Rinse, Repeat, Ship"
The "least possible" part is important. It makes sure the cycles stay
short (ideally, just a few minutes), and that you don't write any code
for which you don't have tests. If you buy into that plan, then I see
nothing wrong with your suggested solution.
(*) I still believe in TDD, but I don't practice it quite as
enthusiastically as I used to. Which probably means my code isn't as
good as it used to be.
More information about the Python-list
mailing list