What's wrong with this code snippet?

Dave Hansen iddw at hotmail.com
Wed Jan 4 18:52:25 EST 2006


You've received good answers to your original question.  Just a side
issue...

On Wed, 4 Jan 2006 22:19:27 +0000 (UTC) in comp.lang.python, Karlo
Lozovina <_karlo_ at _mosor.net_> wrote:

[...]
>    def GenerateRandomColour():
>        rn.seed()
>        colour = rn.choice(['C', 'P', 'Z'])
>        return colour

I'm not sure what rn is, but it looks like a standard library
random.Random object.  If so, I don't think you want to seed your PRNG
each time you use it -- your numbers might be much less random that
way.  If it is the standard library object, the PRNG is seeded when
the module is first imported, so you may not need to seed it at all.

Regards,
                                        -=Dave

-- 
Change is inevitable, progress is not.



More information about the Python-list mailing list