random function with strings

ataraxia2500 messageboardfan1 at yahoo.com
Sat Jun 21 22:55:11 EDT 2003


I have a function that goes through a directory and I would like to remove
randomly one of the files contained in that directory. I checked out the
random() function in the documentation but it only deals with integers.

here's what my function looks like: 

with os.path.walk
def delete_backups(arg, dirname, names):
 /*here I need a function that select a file randomly and, let's  call it
"name", then I do this:*/
            os.remove(os.path.join(dirname, name))

any suggestions?

thanx in advance




More information about the Python-list mailing list