inspect.formatannotation
Prev: inspect.findsource | Up: inspect | Next: inspect.formatannotationrelativeto
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.formatannotation
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import formatannotation
Signature & Overview
inspect.formatannotation(annotation, base_module=None, *, quote_annotation_strings=True)
inspect.formatannotation() function.
Usage
import inspect
assert inspect.formatannotation(int) == "int"
assert inspect.formatannotation("MyType") == "'MyType'"
Gotchas
- Formatting helper used by
Signature.__str__(): Stripsbuiltins.prefix for built-in types.
REPL Inspect
from inspect import formatannotation
help(formatannotation)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/findsource Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/formatannotationrelativeto 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