The current syntax file is out of date for Python 3. I’ve made an attempt to update or correct the lists of exceptions/builtins/types, if anyone else finds it useful.
--- Python.sublime-syntax 2016-02-28 10:00:42.000000000 -0800
+++ Python.sublime-syntax 2016-02-28 12:17:13.000000000 -0800
@@ -61,7 +61,7 @@
- match: \b(and|in|is|not|or)\b
comment: keyword operators that evaluate to True or False
scope: keyword.operator.logical.python
- - match: \b(as|assert|del|exec|print)\b
+ - match: \b(as|assert|del)\b
comment: keywords that haven't fit into other groups (yet).
captures:
1: keyword.other.python
@@ -71,7 +71,7 @@
scope: keyword.operator.comparison.python
- match: \+\=|-\=|\*\=|/\=|//\=|%\=|&\=|\|\=|\^\=|>>\=|<<\=|\*\*\=
scope: keyword.operator.assignment.augmented.python
- - match: \+|\-|\*|\*\*|/|//|%|<<|>>|&|\||\^|~
+ - match: \+|\-|\*|\*\*|/|//|%|<<|>>|&|\||\^|~|@
scope: keyword.operator.arithmetic.python
- match: \=
scope: keyword.operator.assignment.python
@@ -392,35 +392,35 @@
- match: |-
(?x)\b(
(
- Arithmetic|Assertion|Attribute|BlockingIO|BrokenPipe|Buffer|ChildProcess|
- Connection(Aborted|Refused|Reset)?|EOF|Environment|FileExists|
- FileNotFound|FloatingPoint|Interrupted|IO|IsADirectoryError|
- Import|Indentation|Index|Key|Lookup|Memory|Name|NotADirectory|
- NotImplemented|OS|Overflow|Permission|ProcessLookup|Reference|
- Runtime|Standard|Syntax|System|Tab|Timeout|Type|UnboundLocal|
- Unicode(Encode|Decode|Translate)?|Value|VMS|Windows|ZeroDivision
+ Arithmetic|Assertion|Attribute|BlockingIO|BrokenPipe|Buffer|
+ ChildProcess|Connection(Aborted|Refused|Reset)?|EOF|Environment|
+ FileExists|FileNotFound|FloatingPoint|Import|Index|Interrupted|IO|
+ IsADirectoryError|Indentation|Key|Lookup|Memory|Name|NotADirectory|
+ NotImplemented|OS|Overflow|Permission|ProcessLookup|Recursion|
+ Reference|Runtime|Syntax|System|Tab|Timeout|Type|UnboundLocal|
+ Unicode(Decode|Encode|Translate)?|Value|ZeroDivision
)Error|
- ((Pending)?Deprecation|Runtime|Syntax|User|Future|Import|Unicode|Bytes)?Warning|
- (Base)?Exception|
- SystemExit|StopIteration|NotImplemented|KeyboardInterrupt|GeneratorExit
+ ((Pending)?Deprecation|Bytes|Future|Import|Resource|Runtime|Syntax|Unicode|User)?Warning|
+ (Base)?Exception|GeneratorExit|KeyboardInterrupt|StopAsyncIteration|
+ StopIteration|SystemExit
)\b
scope: support.type.exception.python
builtin_functions:
- match: |-
(?x)\b(
- __import__|all|abs|any|apply|ascii|bin|callable|chr|classmethod|cmp|coerce|
- compile|delattr|dir|divmod|enumerate|eval|execfile|filter|format|getattr|
- globals|hasattr|hash|help|hex|id|input|intern|isinstance|issubclass|iter|
- len|locals|map|max|min|next|oct|open|ord|pow|print|property|range|
- raw_input|reduce|reload|repr|reversed|round|setattr|sorted|staticmethod|
- sum|super|type|unichr|vars|zip
+ __import__|abs|all|any|ascii|bin|callable|chr|compile|copyright|
+ credits|delattr|dir|divmod|eval|exec|exit|format|getattr|globals|
+ hasattr|hash|help|hex|id|input|isinstance|issubclass|iter|len|
+ license|locals|max|min|next|oct|open|ord|pow|print|quit|repr|round|
+ setattr|sorted|sum|vars
)\b
scope: support.function.builtin.python
builtin_types:
- match: |-
(?x)\b(
- basestring|bool|buffer|bytearray|bytes|complex|dict|float|frozenset|int|
- list|long|memoryview|object|range|set|slice|str|tuple|unicode|xrange
+ bool|bytearray|bytes|classmethod|complex|dict|enumerate|filter|float|
+ frozenset|int|list|map|memoryview|object|property|range|reversed|set|
+ slice|staticmethod|str|super|tuple|type|zip
)\b
scope: support.type.python
constant_placeholder:
@@ -503,7 +503,7 @@
generic_names:
- match: "[A-Za-z_][A-Za-z0-9_]*"
illegal_names:
- - match: \b(and|as|assert|break|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|not|or|pass|print|raise|return|try|while|with|yield)\b
+ - match: \b(and|as|assert|break|class|continue|def|del|elif|else|except|finally|for|from|global|if|import|in|is|lambda|nonlocal|not|or|pass|raise|return|try|while|with|yield)\b
scope: invalid.illegal.name.python
keyword_arguments:
- match: '\b([a-zA-Z_][a-zA-Z_0-9]*)\s*(=)(?!=)'
@@ -527,15 +527,13 @@
magic_function_names:
- match: |-
(?x)\b(__(?:
- abs|add|and|call|cmp|coerce|complex|contains|del|delattr|
- delete|delitem|delslice|div|divmod|enter|eq|exit|float|
- floordiv|ge|get|getattr|getattribute|getitem|getslice|gt|
- hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imod|imul|init|
- int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len|
- long|lshift|lt|mod|mul|ne|neg|new|nonzero|oct|or|pos|pow|
- radd|rand|rdiv|rdivmod|repr|rfloordiv|rlshift|rmod|rmul|ror|
- rpow|rrshift|rshift|rsub|rtruediv|rxor|set|setattr|setitem|
- setslice|str|sub|truediv|unicode|xor
+ abs|add|and|call|cmp|complex|contains|del|delattr|delete|delitem|div|
+ divmod|enter|eq|exit|float|floordiv|ge|get|getattr|getattribute|
+ getitem|gt|hash|hex|iadd|iand|idiv|ifloordiv|ilshift|imod|imul|init|
+ int|invert|ior|ipow|irshift|isub|iter|itruediv|ixor|le|len|lshift|lt|
+ matmul|mod|mul|ne|neg|new|nonzero|oct|or|pos|pow|radd|rand|rdiv|
+ rdivmod|repr|rfloordiv|rlshift|rmod|rmul|ror|rpow|rrshift|rshift|
+ rsub|rtruediv|rxor|set|setattr|setitem|str|sub|truediv|xor
)__)\b
comment: these methods have magic interpretation by python and are generally called indirectly through syntactic constructs
scope: support.function.magic.python