Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

baseconv

Copyright (c) 2010, 2011, 2012 Guilherme Gondim. All rights reserved.

Copyright (c) 2009 Simon Willison. All rights reserved.

Copyright (c) 2002 Drew Perttula. All rights reserved.

Description:
Convert numbers from base 10 integers to base X strings and back again.
Author(s):
Drew Perttula, Simon Willison, Guilherme Gondim
License:
Python Software Foundation License version 2
Project website:
https://bitbucket.org/semente/baseconv/
References:
http://www.djangosnippets.org/snippets/1431/ ; http://code.activestate.com/recipes/111286/

Sample usage

>>> base20 = BaseConverter('0123456789abcdefghij')
>>> base20.encode(1234)
'31e'
>>> base20.decode('31e')
'1234'
>>> base20.encode(-1234)
'-31e'
>>> base20.decode('-31e')
'-1234'
>>> base11 = BaseConverter('0123456789-', sign='$')
>>> base11.encode('$1234')
'$-22'
>>> base11.decode('$-22')
'$1234'

License information

See the file "LICENSE" for terms & conditions for usage, and a DISCLAIMER OF ALL WARRANTIES.

This baseconv distribution contains no GNU General Public Licensed (GPLed) code, just like prior baseconv distributions.

All trademarks referenced herein are property of their respective holders.

Django

The Django Project includes a copy of this module on django.utils.baseconv.

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.