On this page
  1. inspect.getcomments
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

inspect.getcomments

Prev: inspect.getclosurevars | Up: inspect | Next: inspect.getcoroutinelocals
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getcomments
Tags: #public #python3 #stdlib #inspect


Import

import inspect
from inspect import getcomments

Signature & Overview

inspect.getcomments(object)

Get lines of comments immediately preceding an object's source code.

Usage

import inspect
import json

# Returns comment lines immediately preceding an object's definition (or None)
c = inspect.getcomments(json)
assert c is None or isinstance(c, str)

Gotchas

REPL Inspect

from inspect import getcomments
help(getcomments)

Linked from

Related notes