Somehow, I often find myself wanting the binary representation of an integer.

Well, Python of course has the builtin bin function, but the output always begins with a pesky 0b.

Furthermore, bin doesn’t support padding the binary to a certain length (e.g. 8 bits). So, I use string format:

>>> bin(63)

>>> '{0:08b}'.format(63)

Just for fun, here is a somewhat comical and more complicated example for converting an ascii string to binary:

>>> s = "foo"
>>> ("{:08b}"*len(s)).format(*map(ord,s))

Format has many more features and reminds me of printf in some ways. I highly recommend checking out the documentation.