[Zope] Random Module

Aaron Bauman abauman at gaycenter.org
Fri Aug 26 12:52:54 EDT 2005


>From ZopeBook 2.6:
<quote>
Using a module usage (pick a random choice from a list):

<span tal:replace="python:modules['random'].choice(['one',
'two', 'three', 'four', 'five'])">
a random number between one and five
</span>
</quote>

Substitute any list you wish...

to generate a random number [ 0 < x < 1 ), you'd just use something like
<quote>
<tal:define define="random_floating_point_number
python:modules['random'].random()" />
</quote>

I'd be curious to know if the random() method DOESN't work, 
cause the choice method has definitely worked for me...

Hope it helps,
-
Aaron Bauman
http://www.gaycenter.org



-----Original Message-----
From: David Siedband [mailto:david at generation-xml.com] 
Sent: Thursday, August 25, 2005 2:38 PM
To: ZOPE.org
Subject: Re: [Zope] Random Module

Are you sure you can't import the functions you need?  It might be
worthwhile to see if what you want to do can be done without adding to your
allowed modules.  That should be kind of a last resort.  I'm curious what
kind of functionality you need from random that can't be done within the
importable functions...
--
David


On Aug 25, 2005, at 10:36 AM, Sam Boggess wrote:

> Why won't Zope let me call the random module?  It's really annoying to 
> have to write an external method to call such a simple tool.  Is there 
> a way around this?  Thanks.





More information about the Zope mailing list