A Python utility for encoding/decoding arbitrary-base numbers.
Minor doctest and README updates; bump to v1.0.2
added usage examples to README

heads

tip
browse log

clone

read-only
https://hg.sr.ht/~paulbissex/basewhat
read/write
ssh://hg@hg.sr.ht/~paulbissex/basewhat

#basewhat

A Python utility for encoding/decoding arbitrary-base numbers.

Usage:

>>> b16 = BaseWhat(base=16)
>>> b16.from_int(65535)
'FFFF'
>>> b16.to_int('DECAFBAD')
3737844653
>>> b32 = BaseWhat(digits="23456789ABCDEFGHJKLMNPQRSTUVWXYZ")
>>> b32.from_int(32767)
'ZZZ'
>>> b32.from_int(9223372036854775808)
'A222222222222'
>>> b32.to_int('1900MIXALOT')
Traceback (most recent call last):
...
ValueError: Not a valid base 32 number

Project home page: https://sr.ht/~paulbissex/Basewhat/

Author: Paul Bissex paul@bissex.net