title: Random Password Generator quality
body: <p>I have been asked to develop a random password generator based on different character sets, like 'abcd.....wxyz', '0123456789' and '!$()?=^_;:,.-'.</p>
  <p>I have now in mind two different implementations:</p>
  <ol>
  <li>In this case, all characters set are copied into a single string, then each character that composes the password is taken randomly from it.</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code>    import os, random, string
  
      length = 13
      chars = string.ascii_letters + string.digits + '!$()?=^_;:,.-'
      random.seed = (os.urandom(1024))
  
      print ''.join(random.choice(chars) for i in range(length))
  </code></pre>
  <ol start="2">
  <li>The character sets are divided and a random value is used to select among the sets and then, from that selected set, a random character is taken</li>
  </ol>
  <pre class="lang-py prettyprint-override"><code>    import os, random, string
  
      length = 13
      set = [string.ascii_letters, string.digits, '!$()?=^_;:,.-']
  
      random.seed = (os.urandom(1024))
  
      print ''.join(random.choice(random.choice(set)) for i in range(length))
  
  </code></pre>
  <p>From multiple tests it seems that the second solution generates passwords that contain more symbols and numbers, this is due to the fact that the probability to use a symbol is exactly 1/3 (33%). While in the first algorithm only 13/(10+13+26) = 26%.</p>
  <p>Which one is the correct implementation? I think that the first algorithm has a non-uniform probability with the respect to the set selection, making more probable to find ascii_letters with the respect to the symbols.
  Any hints would be appreciated.</p>
  <p>Edit: I did this implementation only for explaining the two different implementations in a fast way. Surely I'll select the best suitable module, but for now I'm not interested in this evaluation.</p>