title: Python 3 encoding or errors without a string argument
body: <p>I had a function in <strong>Python 2</strong> which I used to generate a 22 length random string from a UUID....</p>
  
  <pre><code>def make_base64_string():
      return uuid.uuid4().bytes.encode("base64")[:22]
  </code></pre>
  
  <p>I have since started to test in Python 3 and just finished watching the <a href="http://nedbatchelder.com/text/unipain.html" rel="nofollow">Pragmatic Unicode presentation</a>, most of which went way over my head. Anyway, I didn't assume this function would now work in Python 3.4 and I was right....</p>
  
  <p>So next, I tried what I was hoping was the solution giving that <code>bytes.encode</code> from my understating is gone... (treat everything as a byte, right?).</p>
  
  <pre><code>base64.b64encode(bytes(uuid.uuid4(), 'utf-8'))
  </code></pre>
  
  <p>but this gives me the following error...</p>
  
  <pre><code>Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: encoding or errors without a string argument 
  </code></pre>
  
  <p>Why? I would like to understand this more.</p>