Is random.sample truly random?
<p>I have a list with <code>155k</code> files. When I <code>random.sample(list, 100)</code>, while the results are not the same from the previous sample, they look similar. </p>

<p>Is there a better alternative to <code>random.sample</code> that returns a new list of random 100 files? </p>

<pre><code>folders = get_all_folders('/data/gazette-txt-files')
# get all files from all folders
def get_all_files():
    files = []
    for folder in folders:
        files.append(glob.glob("/data/gazette-txt-files/" + folder + "/*.txt"))

    # convert 2D list into 1D
    formatted_list = []
    for file in files:
        for f in file:
            formatted_list.append(f)

    # 200 random text files
    return random.sample(formatted_list, 200)
</code></pre>

<p>You may need to seed the generator. See <a href="https://docs.python.org/2/library/random.html#random.seed" rel="nofollow">here</a> in the Documentation.</p>

<p>Just call <code>random.seed()</code> before you get the samples.</p>

python python-3.x random