[Zope] PHP style variable variables in Python?

Maik Jablonski maik.jablonski@uni-bielefeld.de
Wed, 10 Apr 2002 09:30:51 +0200


On Tue, 09 Apr 2002 23:39:50 -0400 "Michael LaPera" <mlapera@colorbyte.com>
wrote:

> All I want to do do is generate a random number which is concatenated to 
> the end of the context attribute similar to this example in PHP:

try this in a python script and read the ZopeHelp/ApiReference/random.

##############
from random import uniform,random

# Generates a float random between 0 and 1

print random()

# Generates an integer random between 5 and 50

print int(uniform(5,50))

# Generates titleOfCurrentContext_randomNumberBetween1-100

print "%s_%d" % (context.title, int(uniform(1,100)))

return printed
##############

greetings, maik.

-- 
 maik jablonski                  http://www.sachunterricht-online.de
 universitaet bielefeld         http://www.zfl.uni-bielefeld.de
 zentrum fuer lehrerbildung    tlph://+49.(0).521.106.4234