How to encode flickr short url (base58) in python?
<p>How to encode short URLs of Flickr photos? There is no documentation about the <code>base58</code> method on the <a href="https://www.flickr.com/services/api/misc.urls.html" rel="nofollow">official API page about urls</a>.</p>

<p>I can't find examples in Python that are just a function, there are only complicated classes.</p>

<pre><code>def b58encode(fid):
  CHARS = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
  CHAR_NUM = len(CHARS)
  encoded = ''
  fid = int(fid)

  while fid &gt;= CHAR_NUM:
    div, mod = divmod(fid, CHAR_NUM)
    encoded = CHARS[mod] + encoded
    fid = div
  return CHARS[fid] + encoded

print(b58encode(2222223333333))
</code></pre>

<p>Answer based on <a href="https://gist.github.com/mursts/2247355" rel="nofollow">https://gist.github.com/mursts/2247355</a></p>

python url flickr flickr-api