-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Lang] Define __str__ method for DataType #3370
Conversation
✔️ Deploy Preview for jovial-fermat-aa59dc canceled. 🔨 Explore the source changes: f6d9f72 🔍 Inspect the deploy log: https://app.netlify.com/sites/jovial-fermat-aa59dc/deploys/6183503211ce1c00082e1847 |
/cc @ailzhang |
/format |
@@ -103,6 +103,7 @@ void export_lang(py::module &m) { | |||
.def(py::self == py::self) | |||
.def("__hash__", &DataType::hash) | |||
.def("to_string", &DataType::to_string) | |||
.def("__str__", &DataType::to_string) |
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.
do we need add __repr__
too?
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.
SGTM!
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.
__repr__
is more like for debugging purpose which includes object information.
I usually think in this way (maybe incorrect :P):
information from __str__
should be human readable (but can lose info)
But you can use information from __repr__
to reconstruct this object easily.
So IMHO only handling __str__
is good enough for now and we might consider adding __repr__
in the future :D
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.
Nice thanks!
@@ -103,6 +103,7 @@ void export_lang(py::module &m) { | |||
.def(py::self == py::self) | |||
.def("__hash__", &DataType::hash) | |||
.def("to_string", &DataType::to_string) | |||
.def("__str__", &DataType::to_string) |
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.
__repr__
is more like for debugging purpose which includes object information.
I usually think in this way (maybe incorrect :P):
information from __str__
should be human readable (but can lose info)
But you can use information from __repr__
to reconstruct this object easily.
So IMHO only handling __str__
is good enough for now and we might consider adding __repr__
in the future :D
Signed-off-by: knight42 <anonymousknight96@gmail.com>
58165dc
to
f6d9f72
Compare
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.
Thanks!!
cool |
Signed-off-by: knight42 anonymousknight96@gmail.com
fixes #3367