how to do random / SystemRandom switch

Thomas Rachel nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915 at
Sat Apr 30 08:22:59 EDT 2011

Am 30.04.2011 11:10 schrieb Matthias Kievernagel:

> In my top-level script I want to select if my program
> is to use functions or the
> ones.

On which criteria do you fix that?

Anyway, you could use a module

import random

if use_sys:
     randobj = random.SystemRandom()
     randobj = random.Random()

and then use

from myrandom import randobj as random

and then use random's methods (randrange, random, whatever), no matter 
where they come from.


More information about the Python-list mailing list