title: Python 'long' object has no attribute 'to_bytes'?
body: <p>I'm trying to use a bitcoin address validator written in Python from <a href="http://rosettacode.org/wiki/Bitcoin/address_validation#Python" rel="nofollow">here</a>: </p>
  
  <p>This snippet gives me trouble though:</p>
  
  <pre><code>def decode_base58(bc, length):
      n = 0
      for char in bc:
          n = n * 58 + digits58.index(char)
      return n.to_bytes(length, 'big')
  </code></pre>
  
  <p>I understand that n is either an int or a long, but neither has a method called to_bytes, so I don't really understand how this code could have ever worked?</p>
  
  <p>Does anybody know what's wrong here? Am I doing something wrong, or is this code simply written wrong? All tips are welcome!</p>