[sf-lug] "do not be shy" re ThinkPython
asheesh at asheesh.org
Sun Dec 7 21:43:10 PST 2008
On Sun, 7 Dec 2008, Alex Kleider wrote:
> May I take you up on your offer?
> Can you give me a hint how I could use docstring to make Ex 7.5 easier?
> I've been looking at a short file you gave us at one of the classes
> (it's attached) but can't really see how anything there helps.
Well, it's a matter of iterative development.
Basically, I'm thinking, if you're afraid you might have entered this part
then you could write a function that does just that, and then calculate
out the value for k = 1 by hand. Add a doctest to the top that
demonstrates to your confidence that you got it right for k = 1, and if
you're still worried, do the math out by hand and write the doctest for k
= 2. Run the doctest-style main function, and you'll find that your tests
Then you can be confident that when you use that for higher values of k,
you're doing the right calculations.
The secret of success is sincerity. Once you can fake that, you've got
-- Jean Giraudoux
More information about the sf-lug