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\\)\\|bases\\|c\\(?:\\(?:losur\\|od\\)e\\)\\|d\\(?:efaults\\|ict\\|oc\\)\\|firstlineno\\|globals\\|import\\|kwdefaults\\|m\\(?:odule\\|ro\\)\\|name\\|package\\|qualname\\|\\(?:static_attribute\\|type_param\\)s\\)__\\)\\|a\\(?:bs\\|iter\\|ll\\|n\\(?:ext\\|y\\)\\|scii\\)\\|b\\(?:in\\|ool\\|reakpoint\\|yte\\(?:array\\|s\\)\\)\\|c\\(?:allable\\|hr\\|lassmethod\\|omp\\(?:ile\\|lex\\)\\)\\|d\\(?:elattr\\|i\\(?:ct\\|r\\|vmod\\)\\)\\|e\\(?:numerate\\|val\\|xec\\)\\|f\\(?:ilter\\|\\(?:loa\\|orma\\|rozense\\)t\\)\\|g\\(?:etattr\\|lobals\\)\\|h\\(?:as\\(?:attr\\|h\\)\\|e\\(?:lp\\|x\\)\\)\\|i\\(?:d\\|n\\(?:\\(?:pu\\)?t\\)\\|s\\(?:instance\\|subclass\\)\\|ter\\)\\|l\\(?:en\\|ist\\|ocals\\)\\|m\\(?:a[px]\\|emoryview\\|in\\)\\|next\\|o\\(?:bject\\|ct\\|pen\\|rd\\)\\|p\\(?:ow\\|r\\(?:int\\|operty\\)\\)\\|r\\(?:ange\\|e\\(?:pr\\|versed\\)\\|ound\\)\\|s\\(?:et\\(?:attr\\)?\\|lice\\|orted\\|t\\(?:aticmethod\\|r\\)\\|u\\(?:m\\|per\\)\\)\\|t\\(?:\\(?:upl\\|yp\\)e\\)\\|vars\\|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-to-string `(seq symbol-start
                          (or ,@(append python-font-lock-builtin-types
                                        python-font-lock-builtins
                                        python-font-lock-special-attributes))
                          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.")