On this page
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
- Returns
Noneif no preceding comments exist or if source is unavailable.
REPL Inspect
from inspect import getcomments
help(getcomments)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/getclosurevars Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getcoroutinelocals Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/inspect/ArgInfo Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Arguments Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Attribute Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BlockFinder Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BoundArguments shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BufferFlags shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/ClassFoundException shared tags: #inspect, #stdlib