See the docstring of the coding module.
Python program for teaching entropy, entropy coding, error detecting and correcting codes