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

Chris Angelico rosuav at gmail.com
Fri May 11 03:11:19 EDT 2018


On Fri, May 11, 2018 at 12:04 PM, Bob van der Poel <bob at mellowood.ca> wrote:
> I agree with my freind Gene! And, if it is really necessary to retain
> octal, why not preface it with anything BUT a "0". I've been hit by this a
> few times in the past. I used lots of hex over the years, but don't recall
> ever using octal ... except in frustrating moments when I needed to change
> permission bits.

Because if it doesn't start with a 0, it won't look like a number. You
could use &H1A2B for hex (I can't remember what the octal equivalent
was), which consumes the ampersand as a syntactic character; or you
could put a trailing adornment 1A2Bh, which looks like an identifier
if the number starts with a letter. Much cleaner to make the marker
"this is octal" or "this is hex" start with a zero, making it very
clearly a number from the start.

ChrisA



More information about the Python-list mailing list