Sublime Forum

Python syntax highlighting peculiarity

#1

I was typing some Python code in ST4 when I noticed some very peculiar highlighting of arrays as follows and was wondering if anyone knows why this happens?

On lines 44 and 45, any time I insert a “0” before the number “8” or “9” there, it is highlighted as white. If I do that for line 43 or 46, this does not happen. Does anyone else see this? I put the code below so you can test it yourself. Thanks.

adminsub = [
[0, 0, “Calibrate”],
[1, 0, “Reset”],
[2, 0, “Host Open”],
[3, 0, “Host Close”],
[4, 1, “Echo Test”],
[5, 0, “Paddle A2D”],
[6, 0, “Speed A2D”],
[7, 0, “Get Values”],
[08, 0, “(Reserved)”],
[09, 0, “Get FW Major Rev”],
[10, 0, “Set WK1 Mode”],
[11, 0, “Set WK2 Mode”],
[12, 256, “Dump EEPROM”],
[13, 256, “Load EEPROM”],
[14, 1, “Send Message”],
[15, 1, “Load X1MODE”],
[16, 0, “Firmware Update”],
[17, 0, “Set 1200 baud”],
[18, 0, “Set 9600 baud”],
[19, 2, “Set RTTY Mode Registers”],
[20, 0, “Set WK3 Mode”],
[21, 0, “Read Vcc”],
[22, 1, “Load X2MODE”],
[23, 0, “Get FW Minor Rev”],
[24, 0, “Get IC Type”],
[25, 1, “Set Sidetone Volume”]]

0 Likes

#2
  • In Python 2, a leading 0 means octal, so 08 and so on are invalid.
  • Python 3 simply doesn’t allow a leading 0. To represent in octal form, use leading 0o.

08 and so on can be marked as invalid in both cases :thinking: but it looks like it’s unhandled.

0 Likes

#3

Thanks! That is something new to me. I was just using the leading 0’s to pad for alignment. Thanks for clearing this up for me.

Daniel

0 Likes