Leading 0's syntax error in datetime.date module (Python 3.6)

Ian Kelly ian.g.kelly at gmail.com
Thu May 10 13:03:54 EDT 2018


On Thu, May 10, 2018 at 10:36 AM, bartc <bc at freeuk.com> wrote:
> What, 0O100 instead of 0100? Yeah that's a big improvement...
>
> Fortunately octal doesn't get used much.

The PEP discusses this:

"""
Proposed syntaxes included things like arbitrary radix prefixes, such
as 16r100 (256 in hexadecimal), and radix suffixes, similar to the
100h assembler-style suffix. The debate on whether the letter "O"
could be used for octal was intense -- an uppercase "O" looks
suspiciously similar to a zero in some fonts. Suggestions were made to
use a "c" (the second letter of "oCtal"), or even to use a "t" for
"ocTal" and an "n" for "biNary" to go along with the "x" for
"heXadecimal".

For the string % operator, "o" was already being used to denote octal.
Binary formatting is not being added to the % operator because PEP
3101 (Advanced String Formatting) already supports binary, %
formatting will be deprecated in the future.

At the end of the day, since uppercase "O" can look like a zero and
uppercase "B" can look like an 8, it was decided that these prefixes
should be lowercase only, but, like 'r' for raw string, that can be a
preference or style-guide issue.
"""

Personally I would have preferred the "t".



More information about the Python-list mailing list