Variable: python-font-lock-keywords-level-2

python-font-lock-keywords-level-2 is a variable defined in python.el.gz.

Value

(("\\_<def[[:space:]]+\\([_[:alpha:]][_[:word:]]*\\)"
  (1 font-lock-function-name-face))
 ("\\_<class[[:space:]]+\\([_[:alpha:]][_[:word:]]*\\)"
  (1 font-lock-type-face))
 "\\_<\\(?:and\\|del\\|from\\|not\\|while\\|as\\|elif\\|global\\|or\\|with\\|assert\\|else\\|if\\|pass\\|yield\\|break\\|except\\|import\\|class\\|in\\|raise\\|continue\\|finally\\|is\\|return\\|def\\|for\\|lambda\\|try\\|nonlocal\\|async[[:space:]]+\\(?:def\\|for\\|with\\)\\|await\\|match\\|case\\|self\\)\\_>"
 ("\\_<\\(?:__\\(?:\\(?:a\\(?:ll\\|nnotations\\)\\|c\\(?:\\(?:losur\\|od\\)e\\)\\|d\\(?:efaults\\|ict\\|oc\\)\\|globals\\|import\\|kwdefaults\\|\\(?:modul\\|nam\\|packag\\|qualnam\\)e\\)__\\)\\|a\\(?:bs\\|ll\\|ny\\|pply\\|scii\\)\\|b\\(?:asestring\\|in\\|ool\\|reakpoint\\|uffer\\|yte\\(?:array\\|s\\)\\)\\|c\\(?:allable\\|hr\\|lassmethod\\|mp\\|o\\(?:erce\\|mp\\(?:ile\\|lex\\)\\)\\)\\|d\\(?:elattr\\|i\\(?:ct\\|r\\|vmod\\)\\)\\|e\\(?:numerate\\|val\\|xec\\(?:file\\)?\\)\\|f\\(?:il\\(?:e\\|ter\\)\\|\\(?:loa\\|orma\\|rozense\\)t\\)\\|g\\(?:etattr\\|lobals\\)\\|h\\(?:as\\(?:attr\\|h\\)\\|e\\(?:lp\\|x\\)\\)\\|i\\(?:d\\|n\\(?:put\\|t\\(?:ern\\)?\\)\\|s\\(?:instance\\|subclass\\)\\|ter\\)\\|l\\(?:en\\|ist\\|o\\(?:cals\\|ng\\)\\)\\|m\\(?:a[px]\\|emoryview\\|in\\)\\|next\\|o\\(?:bject\\|ct\\|pen\\|rd\\)\\|p\\(?:ow\\|r\\(?:int\\|operty\\)\\)\\|r\\(?:a\\(?:nge\\|w_input\\)\\|e\\(?:duce\\|load\\|pr\\|versed\\)\\|ound\\)\\|s\\(?:et\\(?:attr\\)?\\|lice\\|orted\\|t\\(?:aticmethod\\|r\\)\\|u\\(?:m\\|per\\)\\)\\|t\\(?:\\(?:upl\\|yp\\)e\\)\\|unic\\(?:hr\\|ode\\)\\|vars\\|xrange\\|zip\\)\\_>"
  . font-lock-builtin-face))

Documentation

Font lock keywords to use in python-mode for level 2 decoration.

This is the medium decoration level, including everything in python-font-lock-keywords-level-1, as well as keywords and builtins.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/python.el.gz
(defvar python-font-lock-keywords-level-2
  `(,@python-font-lock-keywords-level-1
    ,(rx symbol-start
         (or
          "and" "del" "from" "not" "while" "as" "elif" "global" "or" "with"
          "assert" "else" "if" "pass" "yield" "break" "except" "import" "class"
          "in" "raise" "continue" "finally" "is" "return" "def" "for" "lambda"
          "try"
          ;; False, None, and True are listed as keywords on the Python 3
          ;; documentation, but since they also qualify as constants they are
          ;; fontified like that in order to keep font-lock consistent between
          ;; Python versions.
          "nonlocal"
          ;; Python 3.5+ PEP492
          (and "async" (+ space) (or "def" "for" "with"))
          "await"
          ;; Python 3.10+
          "match" "case"
          ;; Extra:
          "self")
         symbol-end)
    ;; Builtins
    (,(rx symbol-start
          (or
           "abs" "all" "any" "bin" "bool" "callable" "chr" "classmethod"
           "compile" "complex" "delattr" "dict" "dir" "divmod" "enumerate"
           "eval" "filter" "float" "format" "frozenset" "getattr" "globals"
           "hasattr" "hash" "help" "hex" "id" "input" "int" "isinstance"
           "issubclass" "iter" "len" "list" "locals" "map" "max" "memoryview"
           "min" "next" "object" "oct" "open" "ord" "pow" "print" "property"
           "range" "repr" "reversed" "round" "set" "setattr" "slice" "sorted"
           "staticmethod" "str" "sum" "super" "tuple" "type" "vars" "zip"
           "__import__"
           ;; Python 2:
           "basestring" "cmp" "execfile" "file" "long" "raw_input" "reduce"
           "reload" "unichr" "unicode" "xrange" "apply" "buffer" "coerce"
           "intern"
           ;; Python 3:
           "ascii" "breakpoint" "bytearray" "bytes" "exec"
           ;; Special attributes:
           ;; https://docs.python.org/3/reference/datamodel.html
           "__annotations__" "__closure__" "__code__"
           "__defaults__" "__dict__" "__doc__" "__globals__"
           "__kwdefaults__" "__name__" "__module__" "__package__"
           "__qualname__"
           ;; Extras:
           "__all__")
          symbol-end) . font-lock-builtin-face))
  "Font lock keywords to use in `python-mode' for level 2 decoration.

This is the medium decoration level, including everything in
`python-font-lock-keywords-level-1', as well as keywords and
builtins.")