Closed Chris-May closed 2 years ago
🤖 🤖
Hi! 👋🏽 👋 Welcome to the Exercism Python Repo!
Thank you for opening an issue! 🐍 🌈 ✨
◦ If you'd also like to make a PR to fix the issue, please have a quick look at the Pull Requests doc.
We 💙 PRs that follow our Exercism & Track contributing guidelines!
Please feel free to submit a PR, linking to this issue.
🎉
‼️ Please Do Not ‼️ ❗ Run checks on the whole repo & submit a bunch of PRs. This creates longer review cycles & exhausts reviewers energy & time. It may also conflict with ongoing changes from other contributors. ❗ Insert only blank lines, make a closing bracket drop to the next line, change a word to a synonym without obvious reason, or add trailing space that's not an[ EOL][EOL] for the very end of text files. ❗ Introduce arbitrary changes "just to change things" . _...These sorts of things are **not** considered helpful, and will likely be closed by reviewers._ |
💛 💙 While you are here... If you decide to help out with other open issues, you have our gratitude 🙌 🙌🏽.
Anything tagged with [help wanted]
and without [Claimed]
is up for grabs.
Comment on the issue and we will reserve it for you. 🌈 ✨
Hi @Chris-May 👋🏽
Thanks for filing this issue. 😄
Would there be an appetite to handle both methods? Or am I complicating things?
You are complicating things -- but in the best way. Because there isn't a whole lot of straightforward guidance or examples for overriding or customizing these methods. Worse yet - many libraries and projects don't use these quite correctly either. I remember coming across the Stack Overflow post below at some point, and thinking "I am just going to ignore these two methods, and hope my problem goes away..." 😆 . Of course, it didn't.
Stack Overflow: __str__
vs. __repr__
And within the post is this excellent rundown from Alex Martelli:
Not a Useful Default
So -- TL; DR I think it's a great idea, and I'd love to see if we could add in __str__
vs __repr__
for this exercise. And myself and @J08K would love to see a PR from you around the topic (if you are willing).
But now for the pecked to death by ducks
part ---
For reference, here is the clock
exercise directory:
Clock Exercise Directory
I think my general thoughts would be to keep the instruction_append
as minimal as you can without sacrificing clarity, but that it would also be very useful to set up the __repr__
vs __str__
issue and provide a couple of links and some code examples -akin to what is done for error-handlng
in the circular-buffer
exercise. We don't (yet!) have a concept exercise that covers either classes or dunder methods, so some instruction/example here is probably necessary.
Again - I think its a great idea. Let @J08K or myself know if you are interested in working on this -- and if you need help decoding the docs, or anything else! 🌟 😄
Awesome! I would love to help out with this.
In addition, I'd be interested in helping to create one or more dunder-method exercises. I'm writing a book on classes in python, and I'm thinking about a few anyway. It would be nice to have more of the topic covered in Exercism!
Hi @Chris-May -- apologies for the delay in messaging back. I've assigned you this issue, and I'm delighted you want to take this on!
I would love to chat further about dunder-method exercises -- both our existing practice exercises, and the class
related concept exercises we're about to add. We have a lot of exercises you could potentially work on, should you have the interest and time! 😄
Feel free to reach out to either @J08K or myself if you have questions, issues, or would like to brainstorm ideas. 🌟
That sounds great, @BethanyG! I would be happy to help out as I can!
I've added an initial pull request for you to review. I'm not confident I updated everything I needed to, and I am very much in favor of editing work or any other suggestions you may have for... well, anything.
Thanks for your work!
Oh! In addition, I would love to know what other exercises you'd like help with!
As #2829 is now merged and closed, closing this related issue. Please feel free to re-open should you feel the need. 😄
This issue isn't the biggest of deals, but the python documentation about
__repr__
suggests that:I would imagine the reason the exercise suggests defining the
__repr__
is that every time the student sees errors from the test cases, they'll see thehh:mm
repr, as opposed to the<clock.Clock object at 0x102247190>
repr.Would there be an appetite to handle both methods? Or am I complicating things?
I like that this exercise is an excellent example to show why they might want to implement both
__str__
and__repr__
.