Integer won't fully read as an integer


#1

Writing some python code and doing a tutorial (I’m new to programming). I’ve done a lot of things that worked just fine. Came upon a really weird problem today.

     final = years + months + days + leap_year
     print (final)
     return final
calc_days(05051980,02082016)

The number 02082016 refuses to be accepted as an integer. Atom only reads “020” as an integer, and “82016” as text. If I remove the 8, it works. If I put the 8 back in, it splits it into an integer and code again.

See image below.


#2

I’m pretty sure numbers with a leading 0 in Python are treated as octal literals. Remove the leading 0 and you should be fine.


#3

Ha, only that messes up my code entirely. I parse out the first two digits. Numbers 01-12. That means I’ll have to redo everything…

Oh well, I guess that’s the way it goes.

Thanks for the help!


#4

Ok, time to clarify (sorry, I don’t know Python). If you’re using Python 2.x, then my comment above is correct. HOWEVER, if you’re using Python 3.x, then it is a bug in language-python. If so we’re planning on entirely reworking the language support for Python - you might want to subscribe to https://github.com/atom/language-python/issues/109.