Skip to content

comments

comments

Contains comments added to the document.

CommentsPart

CommentsPart(
    partname: PackURI,
    content_type: str,
    element: CT_Comments,
    package: Package,
)

Bases: StoryPart

Container part for comments added to the document.

Source code in src/docx/parts/comments.py
def __init__(
    self, partname: PackURI, content_type: str, element: CT_Comments, package: Package
):
    super().__init__(partname, content_type, element, package)
    self._comments = element

comments property

comments: Comments

A Comments proxy object for the w:comments root element of this part.

default classmethod

default(package: Package) -> Self

A newly created comments part, containing a default empty w:comments element.

Source code in src/docx/parts/comments.py
@classmethod
def default(cls, package: Package) -> Self:
    """A newly created comments part, containing a default empty `w:comments` element."""
    partname = PackURI("/word/comments.xml")
    content_type = CT.WML_COMMENTS
    element = cast("CT_Comments", parse_xml(cls._default_comments_xml()))
    return cls(partname, content_type, element, package)