pybaco

Python Base Converter


License
GPL-2.0
Install
pip install pybaco==0.3.0

Documentation

pybaco

Python Base Converter - Converts any number base to any number base

Installing

$ pip install pybaco

Usage

from string import digits
from pybaco import Baco, base2, base10, base16

b = Baco(18, base10)
# You need to pass the alphabet you want to convert, in this case, '01' (binary)
b.convert(base2) # 10010

# Shortcuts
# assuming that the number to be converted is in decimal base
Baco.to_bin(18) # 10010
Baco.to_oct(18) # 22
Baco.to_hex(15) # f
Baco.to_36(123456789) # 21i3v9
Baco.to_62(123456789) # 8M0kX

# Specifing the origin base
Baco.to_bin(15, base16) # 1111
Baco.to_62('abc', base16) # ik
Baco.to_dec('a', base16) # 10

Testing

$ python test.py