title: How exactly does random.random() work in python?
body: <p>I am a bit confused about how the random.random() function works in python.</p>
  
  <p>The <a href="https://docs.python.org/3/library/random.html#random.random" rel="noreferrer">docs</a> say that it 'Return the next random floating point number in the range [0.0, 1.0)'. 
  I understand that pseudo-random number generators work by performing some operation on a value. Generally this value is the previous number generated by the generator. So I think that's what <strong>'next random floating point'</strong> means here. (Please correct me if I am wrong)</p>
  
  <p>But when I saw the <a href="https://hg.python.org/cpython/file/3.6/Lib/random.py" rel="noreferrer">source code</a> of the random library, random function is not defined in the <code>class Random</code>. Instead, its defined in the <code>class SystemRandom</code> as follows (line 671 of the code): </p>
  
  <pre><code> def random(self):
          """Get the next random number in the range [0.0, 1.0)."""
          return (int.from_bytes(_urandom(7), 'big') &gt;&gt; 3) * RECIP_BPF
  </code></pre>
  
  <p>If I understand this correctly, this function generates a random number using os.urandom. Which, according to the <a href="https://docs.python.org/2/library/os.html#os.urandom" rel="noreferrer">documentation</a>, returns random bytes from an OS-specific randomness source. So this will not give the 'next' floating point random number.</p>
  
  <p>How are the two connected? or are they two different things? </p>
  
  <p>I am quite confused here. Any kind of help would be appreciated.</p>
  
  <p>Thanks!</p>