Python base conversion.

I need to convert either base 10 or base 16(hex) to base 2(binary) and back again.

  1. What is the easist way to do this?

  2. Would converting from/to base 8(oct) to binary be easier?

You can find one recipe describing how to do this at .

I searched with Google, and I think this is the simpliest example:

(But I did not tried it, so verify first it is doing the counting right!)

Thanks. That helped.
BeBraw’s suggestion was the best for what I needed.