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

bartc bc at freeuk.com
Thu May 10 12:36:39 EDT 2018


On 10/05/2018 12:28, Skip Montanaro wrote:
>>
>> This gave the following error:
>>
>> Syntax Error: invalid token: C:\Users\Virgil Stokes\Desktop\Important
>> Notes_Files\CheckProcessingDate_02.py, line 7, pos 17
>> d0 = date(2018,02,01)
>>
> 
> Note that this is a Python syntax error. It actually has nothing to do with
> the datetime module. In Python before version 3, leading zeroes were how
> you specified octal (base 8) numbers.

I wonder why someone would take a feature generally agreed to be a 
poorly designed feature of C, and incorporate it into a new language.

Especially one with a very different syntax that doesn't need to be 
backwards compatible.

  That changed in Python 3. If you slim
> the start of PEP 3127, you'll learn the new notation.

What, 0O100 instead of 0100? Yeah that's a big improvement...

Fortunately octal doesn't get used much.

-- 
Bartc



More information about the Python-list mailing list