module random: delay in "seeding"

Roman Suzi rnd at onego.ru
Sat May 4 13:27:59 EDT 2002


On Sat, 4 May 2002, Alex Martelli wrote:

>Roman Suzi wrote:
>        ...
>> While it is quite understandable that normally distributed numbers
>> come in pairs, but I thought seed() resets the state of random module...
>
>No, you need getstate and setstate methods for that.  If all you want
>is to also reset the gauss_next attribute, go ahead -- no leading
>underscore, so it's public.  Note that getstate returns the version (to
>check if you ever try to restore state to an incompatible version),
>seed, and gauss_next.  They're also exposed as __getstate__ and
>__setstate__ so you may ALSO pickle/unpickle random.Random
>instances and also copy.copy them.
>
>> I think this sometimes can cause errors.
>
>If so, then the docs need to be made clearer; it seems to me that
>the mechanisms are just fine.

Yes, I oversaw the whole set/getstate thingie. Thanks for pointing 
this! (I was using Python 1.5.2...)

Sincerely yours, Roman Suzi
-- 
\_ Russia \_ Karelia \_ Petrozavodsk \_ rnd at onego.ru \_
\_ Saturday, May 04, 2002 \_ Powered by Linux RedHat 7.2 \_
\_ "Is there life before coffee?" \_






More information about the Python-list mailing list