On this page
annotationlib.Format
Prev: annotationlib.call_evaluate_function | Up: annotationlib | Next: annotationlib.ForwardRef
Rel: annotationlib.annotations_to_string, annotationlib.call_annotate_function, annotationlib.call_evaluate_function, annotationlib.ForwardRef
Ref: docs.python.org — annotationlib.Format
Tags: #public #python3 #stdlib #annotationlib
Import
import annotationlib
from annotationlib import Format
Signature & Overview
annotationlib.Format(*values)
annotationlib.Format class.
Methods & Attributes
Format.as_integer_ratio(self, /)— Return a pair of integers, whose ratio is equal to the original int.Format.bit_count(self, /)— Number of ones in the binary representation of the absolute value of self.Format.bit_length(self, /)— Number of bits necessary to represent self in binary.Format.conjugate(self, /)— Returns self, the complex conjugate of any int.Format.from_bytes(bytes, byteorder='big', *, signed=False)— Return the integer represented by the given array of bytes.Format.is_integer(self, /)— Returns True. Exists for duck type compatibility with float.is_integer.Format.to_bytes(self, /, length=1, byteorder='big', *, signed=False)— Return an array of bytes representing an integer.
Usage
import annotationlib
# Python 3.14+ enum controlling deferred annotation evaluation (VALUE, FORWARDREF, STRING)
assert annotationlib.Format.VALUE.value == 1
assert annotationlib.Format.STRING.value == 3
Gotchas
- Requires Python 3.14+ (PEP 649): Use
Format.STRINGto inspect annotations safely even when forward references aren't defined yet.
REPL Inspect
from annotationlib import Format
help(Format)
Linked from
- tuts/python3/stdlib_module/annotationlib
- tuts/python3/stdlib_module/annotationlib/annotations_to_string
- tuts/python3/stdlib_module/annotationlib/call_annotate_function
- tuts/python3/stdlib_module/annotationlib/call_evaluate_function
- tuts/python3/stdlib_module/annotationlib/ForwardRef
- tuts/python3/stdlib_module/annotationlib/get_annotate_from_class_namespace
- tuts/python3/stdlib_module/annotationlib/get_annotations
- tuts/python3/stdlib_module/annotationlib/type_repr
Related notes
- tuts/python3/stdlib_module/annotationlib/annotations_to_string Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/call_annotate_function Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/call_evaluate_function Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/ForwardRef Linked here; links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/annotationlib/get_annotate_from_class_namespace links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/get_annotations links to this page; shared tags: #annotationlib, #stdlib
- tuts/python3/stdlib_module/annotationlib/type_repr links to this page; shared tags: #annotationlib, #stdlib
- tuts/c/stdlib shared tags: #stdlib
- tuts/c/stdlib/assert shared tags: #stdlib