>> # Python-2, sorry
>> import os
>> print list(set(open('/usr/share/dict/words')))[os.getpid():][:4]

> So that steps by your pid? 

Not really. It seems to rely on list(set(...)) kinda randomizing order... which 
is definitely not safe without hash randomization.  

But this brings up an interesting concept... if we can assume Python 2.7 with 
the -R flag, or Python 3.3+, I think we do get true pseudo-randomization out of 
list(set(...))... which means we can trim some!

print(list(set(open('/usr/share/dict/words')))[:4])

No module imports needed! Although it's not as pretty as the original post, but 
neither was Roy's.

-Nick Cash
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to