Path: csiph.com!x330-a1.tempe.blueboxinc.net!aioe.org!news.mixmin.net!newsfeed.straub-nv.de!noris.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: Thomas Rachel Newsgroups: comp.lang.python Subject: Re: how to do random / SystemRandom switch Date: Sat, 30 Apr 2011 14:22:59 +0200 Organization: A newly installed InterNetNews server Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; U; Linux i686; de; rv:1.9.2.14) Gecko/20110221 SUSE/3.1.8 Thunderbird/3.1.8 In-Reply-To: Lines: 27 NNTP-Posting-Date: 30 Apr 2011 14:30:04 CEST NNTP-Posting-Host: 1712af42.newsspool2.arcor-online.net X-Trace: DXC=YM<6[86H5V<^cW`WBF>WQjXI@CI3 X-Complaints-To: usenet-abuse@arcor.de Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:4197 Am 30.04.2011 11:10 schrieb Matthias Kievernagel: > In my top-level script I want to select if my program > is to use random.xxx functions or the random.SystemRandom.xxx > ones. On which criteria do you fix that? Anyway, you could use a module myrandom.py: import random if use_sys: randobj = random.SystemRandom() else: 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. Thomas