Integers with leading zeroes

Chris Angelico rosuav at
Wed Jul 22 03:10:45 CEST 2015

On Wed, Jul 22, 2015 at 10:55 AM, Steven D'Aprano <steve at> wrote:
>> Sometimes these numbers represent codeblocks of a fixed
>> number of digits. Always writing those numbers with this
>> number of digits helps being aware of this. It is also
>> easier for when you need to know how many leading zero's
>> such a number has.
> I'm not sure what you mean here. Python ints don't have a fixed number of
> digits.

Sometimes your numbers carry specific payloads or structures. A few examples:

Date: 20150722 [decimal]
Unix permissions: 10777 [octal]
MAC address: 0014a466fba9 [hex]

In the MAC address example, it doesn't make sense to elide the leading
zeroes. I can't currently think of a common, real-world example that
uses decimal and isn't gong to push itself to the full eight digits,
apart from Northern Territory postcodes with their silly 08nn pattern,
but I'm sure they exist.


More information about the Python-list mailing list