compas
compas copied to clipboard
Use `__str__` to replaced `print_hierarchy`
According to @chenkasirer there are some discussion about remove all print
in core library, instead use __str__
for this type of functionalities.
https://github.com/BlockResearchGroup/compas_model/pull/31#discussion_r1519911684
I made this change for Tree
, let me know what you guys think.
What type of change is this?
- [ ] Bug fix in a backwards-compatible manner.
- [x] New feature in a backwards-compatible manner.
- [x] Breaking change: bug fix or new feature that involve incompatible API changes.
- [ ] Other (e.g. doc update, configuration, etc)
Checklist
Put an x
in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.
- [x] I added a line to the
CHANGELOG.md
file in theUnreleased
section under the most fitting heading (e.g.Added
,Changed
,Removed
). - [x] I ran all tests on my computer and it's all green (i.e.
invoke test
). - [x] I ran lint on my computer and there are no errors (i.e.
invoke lint
). - [ ] I added new functions/classes and made them available on a second-level import, e.g.
compas.datastructures.Mesh
. - [ ] I have added tests that prove my fix is effective or that my feature works.
- [x] I have added necessary documentation (if appropriate)
this looks great, but curious what's @tomvanmele @Licini take on str vs repr: could repr just invoke str?
the point of __repr__
is to allow for (re)construction of an object using eval
of its string "repr"esentation. in the case of making something print-friendly we should use __str__
in my opinion. if i remember correctly, we only implement __repr__
if reconstruction is indeed possible...
right, repr(oduction) its a neat feature, so repr can echo str when reconstruction isn't viable
@Licini sorry to ping, I'd just like to merge https://github.com/BlockResearchGroup/compas_model/pull/31 soon
@Licini would indeed be good to finish this...
@chenkasirer @gonzalocasas Sorry for late update on this folks. But now I can declare this is done 😂. If you guys give me a go I will merge now