Measure class, precision, significant digits, and divmod()

Ken Starks straton at lampsacos.demon.co.uk
Tue Jul 15 16:56:53 EDT 2008


Ethan Furman wrote:
> Hey all.
> 
<snip>
> 
> As I have mentioned before, I am making this Measure class for two 
> reasons:  experience with unit testing, I like playing with numbers, I 
> am unaware of anything like this having yet been done (okay, three 
> reasons ;).
> 
<snip>
> 
> Any and all feedback welcome, particularly from anyone who might 
> actually use the Measure class.  ;)
> 
> ~Ethan


I have been following this thread with interest, because i am doing 
something similar, namely writing python to provide myself with
experience with unit tests and i like playing with numbers.

In my case the numbers are 'long rationals' (infinite precision)
and will include both floats, the decimal type, extended 'decimals'
-- i.e. possibly with a repeating expansion (or in any base) --
  and finite continued fractions as derived classes.


I also hope to deal with repeating continued fractions later.

+++++++++++++++++++++++++++++++++++++++

My principal interest in your work, however, is in the use of
unit tests as a pedagogical method of teaching programming, whether
self-taught or taught by an instructor.

The students would be taught how to __run__ a unit test-suite
at as early an opportunity as possible. I can't see
why an eleven or twelve year old should not be able to cope
with it in hour one or two of a carefully structured course.

What is needed for such an approach is a copy--in a public
place--of your unit tests for all methods
that are really part of the funtionality; together with
blanked-out definitions for them (i.e just the first line,
any in-code documentation, and 'pass' ).

You would not include any 'internal' methods that are merely the way
__you__ happened to achieve the result.

The programming 'exercise' would then be for the students, or
groups of students, to roll their own version until their code
passed all the unit tests.



More information about the Python-list mailing list