[Python-Dev] Unittests

Patrick K. O'Brien pobrien@orbtech.com
Wed, 10 Apr 2002 15:45:15 -0500

> >
> > You won't have much luck in doing s/whrandom/random/g on a
> > hard-copy Python text book and this is what Python newbies
> > read. I'm not even talking about potential Python users who
> > haven't gotten the slightest idea what sed is... :-)
> What Python textbooks use whrandom?

A couple of weeks ago I replaced code of my own that used whrandom. And I
can tell you exactly what originally lead me astray. I had found a routine
in Zope similar to what I needed and it used whrandom. A check in Python
Essential Reference (first edition) confirmed what I needed to know, made no
mention that whrandom was deprecated, and made it appear that going directly
to whrandom was a shorter path for the functions I needed.

Specifically, the functions choice, randint, random and seed are all listed
under whrandom, are not repeated under random, and the description under
random says that "The module also exports the choice(), randint(), random(),
and uniform() functions from the whrandom module."

Even the more recently published "Python Standard Library" book makes no
mention of whrandom being deprecated. It says "The random module provides a
number of different random number generators. The whrandom module is
similar, but it also allow you to create multiple generator objects." (Kind
of makes whrandom sound superior, doesn't it?)

The Python 2.1 Bible, however, does better. "Prior to Version 2.1, the
random module used the whrandom module - which provides much of the same
functionality - however, the whrandom module is now deprecated."

That said, I'm not opposed to getting rid of cruft. And you'd have to be a
really raw newbie not to realize that there are going to be some
discrepancies between published books and current reality.

Patrick K. O'Brien