[Chicago] Python head-scratcher

Adam "Cezar" Jenkins emperorcezar at gmail.com
Sun Mar 29 20:22:51 CEST 2015


That's pretty awesome. I love when a language help keep my from shooting
myself in the foot as I'm ought to do.

----------------------------------------------------------------------------------
Father, dabbling at being a Python developer specializing in Django,
Cyclist, and home brewer.

On Sun, Mar 29, 2015 at 10:34 AM, Nick Timkovich <prometheus235 at gmail.com>
wrote:

> Note that in Python 3, the first date would also cause a SyntaxError.
> Octal literals must start with "0o" just like hex ("0x") and binary ("0b").
>
> On Sat, Mar 28, 2015 at 1:55 AM, Lewit, Douglas <d-lewit at neiu.edu> wrote:
>
>> Thanks Robert.  I haven't played around with octal numbers in a while.
>> This was interesting.  Thanks for sharing.
>>
>> On Fri, Mar 27, 2015 at 7:43 PM, Robare, Phillip (Randstant) <
>> proba at allstate.com> wrote:
>>
>>> The problem is that a leading zero on a number declares that string to
>>> be octal (base 8), and so only comprised of digits 1 to 7.
>>>
>>>
>>> -----Original Message-----
>>> From: Robare, Phillip (Randstant)
>>> Sent: Friday, March 27, 2015 2:44 PM
>>> To: 'The Chicago Python Users Group'
>>> Subject: Python head-scratcher
>>>
>>> I got an instant message this morning from a frustrated co-worker who
>>> was trying to get his unit tests to run.  He said that when he ran with a
>>> date of June 1 specified things went fine, but specifying August first gave
>>> him a syntax error.  The only change he was making was to change the "6" in
>>> the month field to an "8".  I was able to help him, but I thought those on
>>> this list might enjoy the puzzle.
>>>
>>> >>> from datetime import date
>>> >>> d = date(2014,06,01)
>>> >>> print d
>>> 2014-06-01
>>> >>> d = date(2014,08,01)
>>>   File "<stdin>", line 1
>>>     d = date(2014,08,01)
>>>                    ^
>>> SyntaxError: invalid token
>>>
>>> (for those whose mail readers do not use fixed width fonts, the caret in
>>> the error is pointing at the 8.)
>>>
>>> Clue:  A similar problem would exist in Java, C++, C and many others.
>>>
>>> I will post the solution later today.
>>>
>>> Phil Robare
>>> probare at rcnchicago.com
>>>
>>>
>>> _______________________________________________
>>> Chicago mailing list
>>> Chicago at python.org
>>> https://mail.python.org/mailman/listinfo/chicago
>>>
>>
>>
>> _______________________________________________
>> Chicago mailing list
>> Chicago at python.org
>> https://mail.python.org/mailman/listinfo/chicago
>>
>>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> https://mail.python.org/mailman/listinfo/chicago
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20150329/13276ab2/attachment.html>


More information about the Chicago mailing list