what is the %o in this python file?

python

Solution

`%o` is string formatting. You use `%o` for octal numbers (i.e base 8 numbers):

>>> print "%o" % 011
11
>>> print "%o" % 8
10 # Because 010 == 8

Problem

Here below is the expression of python. It converts integer to binary. ``` >>>octtab = {'0':'000', '1':'001', '2':'010', '3':'011', '4':'100', '5':'101', '6':'110', '7':'111'} >>>def bin1(d, width=0): "integer to binary (string)" s = "%o" % d b = '' for el in s: b += octtab[el] if width > 0: if len(s) > width: return b[:width] b = b.zfill(width) return b ``` I don't know the meaning of %o. Thanks in advance :)

Original source