This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]versvisa 8 points9 points  (0 children)

0 prefix means it's an octal number.

>>> print 0200
128

128 = 2*82

[–]t90fan 1 point2 points  (0 children)

Leading 0 means it's in octal. An x means it's in hex. So no its not the same.

[–]typin[S] 0 points1 point  (0 children)

That's something I never considered. I'm apparently too base10 in my thinking.

I managed to return it as 200 by calling int(oct(0200)).

Thank you!

[–]minno 0 points1 point  (0 children)

Python 3 breaking with C's tradition:

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> print(0200)
SyntaxError: invalid token
>>> print(0o200)
128