LexerPython: Define different keyword sets for Python 2 and Python 3.

Sun, 17 Mar 2019 12:18:40 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 17 Mar 2019 12:18:40 +0100
changeset 6872
96bb40e987f7
parent 6871
f2be626f4643
child 6873
47804e8cde27

LexerPython: Define different keyword sets for Python 2 and Python 3.

QScintilla/Lexers/LexerPython.py file | annotate | diff | comparison | revisions
--- a/QScintilla/Lexers/LexerPython.py	Sun Mar 17 12:01:49 2019 +0100
+++ b/QScintilla/Lexers/LexerPython.py	Sun Mar 17 12:18:40 2019 +0100
@@ -206,7 +206,21 @@
         @param kwSet number of the keyword set (integer)
         @return string giving the keywords (string) or None
         """
-        return QsciLexerPython.keywords(self, kwSet)
+        if kwSet == 1:
+            if self.language() in ["Python", "Python2"]:
+                keywords = "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"
+            elif self.language() == "Python3":
+                keywords = "False None True 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"
+            else:
+                keywords = QsciLexerPython.keywords(self, kwSet)
+        
+        return keywords
     
     def maximumKeywordSet(self):
         """

eric ide

mercurial