[Zope] Creating Document with random num as ID? PartII

Pavlos Christoforou pavlos@gaaros.msrc.sunysb.edu
Sat, 17 Apr 1999 18:18:38 -0400 (EDT)


Ooops ...


I sent a buggy method. Should be:
 
 import whrandom
 
 def selection_nr(self,elems,num=15):
     '''selection_nr(self,elems,num=15)
 
     returns a random selection of num elements from list elems without
     replacement'''
 
     if len(elems)<=num:
         return elems
 
     random_list=[]
     for i in range(num):
         elem=whrandom.choice(elems)
         random_list.append(elem)
         elems.remove(elem)
     return random_list


My apologies

Pavlos