How to generate account number?

Tim Chase python.list at
Sat Nov 3 16:34:26 CET 2012

On 11/03/12 08:22, Roy Smith wrote:
> Even better might be base-32 encoding the value.  Strings of
> digits have an information density of about 3.2 bits/char.
> Base-32 is just about as readable, but gives you 5 bits/char, so
> you end up with a few less characters (which you still want to
> chunk into 3 or 4 character groups).

For things that will be read off a screen/paper, I recommend
omitting several letters that are easy to mistake visually:  i/I/l/1
and O/0 in particular.  The VIN (vehicle identification number) on
all US cars avoids these characters[*], making it easier to read
them back without concern for "is that a zero or an oh; and is that
an ell, a one, a lowercase eye, or a capital eye?"  As an encoding

>>> print len(''.join(c for c in (string.ascii_uppercase +
string.digits) if c not in "O0iIl1"))

the number 32 is pretty handy when dealing with binary :-)


The VIN avoids "Q" too and does use the digits 0/1, but the idea
holds.  Make it easy to ready back.

More information about the Python-list mailing list