[Tutor] randomness

Andrew Wilkins toodles@yifan.net
Sat, 16 Jun 2001 15:38:37 +0800


> import os,random
>
files=os.listdir('threadhtml')
filename=''
while not filename:
 n=random.randint(0,100000)
 if not '%i.html'%n in files:
 filename='%i.html'%n

I oughta check it before sending...

>
> But it seems a bit yucky...can someone shed any light on the matter?
>
> Thanks,
>
> Andrew
>
>
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>