Python 2.7 quick reference

20.29. oct(): Convert to base 8

Given a number n,
oct(n) returns a
string containing an octal (base 8) representation of n. Consistent with
Python's convention that any number starting with a zero is
considered octal, the result of this function will always have
a leading zero.