Home
Manage Your Code
Snippet: Crude Random Birth date Generator (Python)
Title: Crude Random Birth date Generator Language: Python
Description: Python code to generate a list of 25 random dates in the range suitable for pasting into excel. Views: 2372
Author: Keith Sanders Date Added: 2/20/2007
Copy Code  
import random
import win32clipboard

def edates(cnt = 25):
  lis = []
  '''Random dates in numeric format for 
     pasting into Excel.'''
  zot = 0
  while zot < cnt:
    lis.append( random.randint(39083, 39447) )
    zot += 1
  return lis
   
def bdates():
  while 1:
    foo = random.randint(39083, 39447)
    yield foo
    
    
def list2clip(foo):
  st = ''
  clp = win32clipboard
  clp.OpenClipboard()
  clp.EmptyClipboard()
  for ozo in foo:
    st += str(ozo) + "\n"       
  clp.SetClipboardText(st)
  clp.CloseClipboard()  
    
if __name__ == "__main__":
  zot = edates()    
  list2clip(zot)