-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add meaningful "representation" formatter to object classes #432
Changes from 5 commits
33111e7
5f90bc0
617b53c
a40a663
46bfd56
2bc7d64
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -191,6 +191,9 @@ def __init__(self, pdo_node, com_record, map_array): | |
self.is_received: bool = False | ||
self._task = None | ||
|
||
def __repr__(self) -> str: | ||
return f"<{type(self).__qualname__} {self.name!r} at COB-ID 0x{self.cob_id:X}>" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you formatting with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @erlend-aasland perhaps you can chime in why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For strings, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To clarify: >>> s = "thing"
>>> f"'{s}'"
"'thing'"
>>> f"{s!r}"
"'thing'"
>>> f"'{s}'" == f"{s!r}"
True |
||
|
||
def __getitem_by_index(self, value): | ||
valid_values = [] | ||
for var in self.map: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a docstring, as it is not obvious what
qualname
means and how it differs fromname
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Updated.
-- Having
qualname
on this object only hurts my eye a little bit, but its due to the special naming regime that pertains to this object only. Addingqualname
to all the others will just be a do-nothing object for the purpose of duck typing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm okay with having it only here. It's purely for internal use right now.