Random text generator

Richard Jones Richard.Jones at fulcrum.com.au
Fri Nov 12 04:49:18 CET 1999


[Rico Albanese]
> Can anyone tell me if there is a random text generator for Python?  I
> have an application that needs to generate a random password for users.
> I have looked at the random and whrandom modules but they seem to create
> random numbers only.
> 
> Thanks in advance for any advice given

   The function you want is whrandom.choice(). See

       http://www.python.org/doc/current/lib/module-whrandom.html

Python 1.5.2 (#3, Apr 19 1999, 13:39:26)  [GCC 2.8.1] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import whrandom, string
>>> whrandom.choice(string.letters + string.digits)
'P'
>>> whrandom.choice(string.letters + string.digits)
'e'
>>> whrandom.choice(string.letters + string.digits)
'n'
>>> whrandom.choice(string.letters + string.digits)
'I'


          Richard






More information about the Python-list mailing list