-1

I tried to find out what this is in Python 2:

>>> x=0100644
>>> x
33188
>>> x=100644
>>> x
100644

As you can see with or without the leading '0', x value is different in Python 2. I am not largely familiar with Python 2 types. Can you help show me what 0100644 is in python 2?

chfw
  • 4,412
  • 2
  • 26
  • 31

1 Answers1

1

In Python 2.x anything with a leading 0 is octal, 0b is binary, 0x is hex.

>>> 0b01010   # binary
10

>>> 01010   # octal
520

>>> 0x01010  # hex
4112

>>> 1010  # decimal
1010
Cory Kramer
  • 107,498
  • 14
  • 145
  • 201
  • 2
    Why did you answer _and_ closevote? Closevoting should suffice aplenty. – John Dvorak Oct 09 '14 at 11:44
  • Because I saw the duplicate, and it only seemed to discuss octal, so I thought I'd show the other interpreted types just for completeness. – Cory Kramer Oct 09 '14 at 11:44
  • If the question is truly a duplicate (and not just similar), you can provide an answer on the duplicate question. – chepner Oct 09 '14 at 12:42