author property

Comment.author property

Returns or sets the author name for a comment.

@property
def author(self) -> str:
    ...

@author.setter
def author(self, value: str):
    ...

Remarks

Cannot be None.

Default is empty string.

Examples

Shows how to print all of a document’s comments and their replies.

doc = aw.Document(MY_DIR + 'Comments.docx')
comments = doc.get_child_nodes(aw.NodeType.COMMENT, True)
# If a comment has no ancestor, it is a "top-level" comment as opposed to a reply-type comment.
# Print all top-level comments along with any replies they may have.
for comment in comments:
    comment = comment.as_comment()
    if comment.ancestor is None:
        print('Top-level comment:')
        print(f'\t"{comment.get_text().strip()}", by {comment.author}')
        print(f'Has {comment.replies.count} replies')
        for comment_reply in comment.replies:
            comment_reply = comment_reply.as_comment()
            print(f'\t"{comment_reply.get_text().strip()}", by {comment_reply.author}')
        print()

See Also