question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Suggestions for making clock exercise more idiomatic

See original GitHub issue

I teach Python and I sometimes send folks I’m mentoring to Exercism for more practice. 👍

I have some suggestions to make the clock exercise feel slightly more Pythonic. As I noted below, I’m very happy to open pull requests for each of these suggestions.

Comparability

Equality of Clock objects is tested, but other comparisons (e.g. < and >) are not checked.

It might be a good exercise to add a few tests implementing those. Most objects that rely on custom equality also implement the other forms of comparability in Python. I’d think it’d go something like this: 00:00 < 00:01 < 23:59.

add method

The add method looks very odd to me. It makes this object feel more JavaScript-like than Python-like.

>>> Clock(6, 15).add(-160) == Clock(3, 35)
True

I’d think either of these options might make more sense:

Option 1: Implementing + and - with integers (either only left-hand or right-hand also):

>>> Clock(6, 15) - 160 == Clock(3, 35)
True

Option 2: Implementing + and - with other Clock objects (this doubles up these objects as both times and time differences, but that may be fine in this case):

>>> Clock(6, 15) - Clock(0, 160) == Clock(3, 35)
True

repr

I’m not sure if this one is necessary, but this seems like the perfect object to test for a nice repr output on:

>>> Clock(6, 15)
Clock(6, 15)

I’d be happy to write a pull request for any/all of these suggestions. I wanted to open an issue for discussion first.

Thoughts on the above suggestions for the clock exercise? 😸

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Mar 22, 2017

Hello @behrtam and @TruthfulTechnology. I was wanting to get started with contributing to exercism and the python/c++ tracks. Would this be an issue that I might be able to pick up?

0reactions
stale[bot]commented, May 6, 2017

This issue has been automatically marked as `on hiatus because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Idioms Exercises: Idioms about Time
Fill-in-the-blank practice exercise on idioms relating to time. ... It may be a good idea to study the list of idioms before trying...
Read more >
30 Time Idioms and Phrases - English Like A Native
Idiom #1: It's high time · Idiom #2: Against the clock · Idiom #3: The eleventh hour · Idiom #4: To make up...
Read more >
23 time idioms to make your writing more interesting - YP
1 against the clock​​ Use: Police are working against the clock to find the evidence they need.
Read more >
12 Fascinating Examples of Idioms About Time - English - Preply
1. Better late than never · 2. On the spur of the moment · 3. Once in a blue moon · 4. Living...
Read more >
60 Idioms To Teach Kids and Use in “Idiom of the Day” Lessons
Example: “Nine o'clock!” said Mia's dad. “It's time to turn off the TV and hit the sack.” 32. Hold your horses. Hold your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found