Skip to content
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

[V3] Implement new Concept Exercise: comparisons #2288

Closed
DavidGerva opened this issue Jul 19, 2020 · 15 comments
Closed

[V3] Implement new Concept Exercise: comparisons #2288

DavidGerva opened this issue Jul 19, 2020 · 15 comments
Assignees

Comments

@DavidGerva
Copy link
Contributor

DavidGerva commented Jul 19, 2020

This issue describes how to implement the comparisons concept exercise for the Python track.

Getting started

Please please please read the docs before starting. Posting PRs without reading these docs will be a lot more frustrating for you during the review cycle, and exhaust Exercism's maintainers' time. So, before diving into the implementation, please read up on the following documents:

Please also watch the following video:

Goal

This concept exercise should teach how basic (non-customized) comparisons work in python and how to use them effectively.

Learning objectives

  • understand all comparison operations in Python have the same priority and are evaluated after arithmetic, shifting, or bitwise operations.
  • understand all comparisons yield the boolean values True and False
  • know that identity comparisons is and is not are for checking an objects identity only
  • understand that == and != compare both the value & type of an object.
  • know where Python has altered the behavior of == and != for certain built-in types (such as numbers), or for standard library types like decimals, and fractions to allow comparison across and within type.
  • know that unlike numeric types, strings (str) and binary sequences (bytes & byte array) cannot be directly compared.
  • understand how comparisons work within built-in sequence types (list, tuple, range) and built-in collection types (set, dict)
  • know about the "special" comparisons None, NotImplemented (comparing either should use identity operators and not equality operators because they are singleton objects) and NaN (NaN is never == to itself)
  • use the value comparison operators ==, >, <, != with numeric types
  • use the value comparison operators ==, >, <, != with non-numeric types
  • use is and is not to check/verify identity

Out of scope

  • rich comparison with __lt__, __le__, __ne__, __ge__, __gt__
  • understanding (and using the concept) that the == operator calls the dunder method __eq__() on a specific object, and uses that object's implementation for comparison. Where no implementation is present, the default __eq__() from generic object is used.
  • overloading the default implementation of the __eq__() dunder method on a specific object to customize comparison behavior.
  • set operations
  • performance considerations

Concepts

  • Comparison priority in Python
  • Comparison operators==, >, <, !=
  • Identity methods is and is not
  • Equality applied to built-in types
  • Equivalence vs equality
  • Inequality

Prerequisites

  • basics
  • bools
  • dicts
  • lists
  • sets
  • strings
  • tuples
  • numbers
  • iteration

Resources to refer to

Hints

  • Referring to one or more of the resources linked above, or analogous resources from a trusted source.

Concept Description

(a variant of this can be used for the v3/languages/python/concepts/<concept>/about.md doc and this exercises introduction.md doc.)

The concept description needs to be filled in here.

Representer

No changes required.

Analyzer

No changes required.

Implementing

Tests should be written using unittest.TestCase and the test file named comparisons_test.py.

Code in the .meta/example.py file should only use syntax & concepts introduced in this exercise or one of its prerequisites.
Please do not use comprehensions, generator expressions, or other syntax not previously covered. Please also follow PEP8 guidelines.

Help

If you have any questions while implementing the exercise, please post the questions as comments in this issue.

@DavidGerva
Copy link
Contributor Author

DavidGerva commented Jul 19, 2020

@BethanyG, please I would like to have a review to this issue. Not sure about (a lot of things and):

  • the rich comparison inside this exercise/issue
  • the english form and use of the word "comparison"
  • do the integer comparison needs a specific issue/exercise?

@BethanyG BethanyG changed the title [Python] Implement new Concept Exercise: comparison [Python] Implement new Concept Exercise: comparisons Jul 22, 2020
@BethanyG
Copy link
Member

@DavidGerva - apologies for taking so long to give you feedback. Thank you so much for filing this issue and for raising questions about it.

I really struggled to zero in on what felt like the "right" collection of functionality here. I am still not sure I got it correct, and we may need to discuss this further with others. As for language -- I changed the title to comparisons on the logic that Python has many methods and implementations of comparison, and we are talking specifically about those and not the general concept.

I think that numbers and floating-point-numbers - or some variants thereof might include comparisons, but that it's fine to have overlap. I think making numeric comparison its own exercise is probably overkill. Still not sure that None and NotImplemented belong -- we may want to remove those.

I added more comparisons for various types, since the Python docs point out that many built-in types have their own comparison rules that might not be intuitive at first glance. I also added an item about comparisons yielding boolean values since we pulled comparison operators out of the booleans exercise. I essentially followed this comparisons entry in the Python language reference, but with a lot less detail.

I moved the __eq__() method and any customization to "out of scope" -- I think language and behavior customizations should be their own exercise -- or at the very least, we should have a "rich comparisons" exercise where we might cover customization.

Having said all that - I am very open to pushback. I could see equal arguments for including comparisons with each built-in type or for pulling it out into an exercise as we have here.

@cmccandless @ErikSchierboom - your thoughts? are we on the right track??

@ErikSchierboom
Copy link
Member

I think that numbers and floating-point-numbers - or some variants thereof might include comparisons, but that it's fine to have overlap. I think making numeric comparison its own exercise is probably overkill. Still not sure that None and NotImplemented belong -- we may want to remove those.

Some overlap is fine here I feel.

I moved the eq() method and any customization to "out of scope" -- I think language and behavior customizations should be their own exercise -- or at the very least, we should have a "rich comparisons" exercise where we might cover customization.

Without having any Python knowledge, it sounds like a sensible thing to do.

@cmccandless
Copy link
Contributor

Sounds good to me!

@BethanyG
Copy link
Member

Oh for &^!#% sake. None of the edits I made to this issue were actually saved. I am so annoyed right now. Apologies everyone for the spam with no purpose. Will re-edit.

@BethanyG
Copy link
Member

Re-edited with details described above. Chime in if this looks strange..

@DavidGerva
Copy link
Contributor Author

Really nice. I'm glad it was useful to raise the doubts.

@Limm-jk
Copy link
Contributor

Limm-jk commented Dec 11, 2020

Hello!
Is this issue in progress?
If not, can I take up the issue?

@BethanyG
Copy link
Member

Hi @Limm-jk ! We'd be delighted if you wanted to take up this issue 🌟 Thank you. 🌈

I don't yet have a concept description (apologies for that), but can work on one today/this weekend & post it here when I'm done. LMK here or in Slack if you have any questions or problems.

Looking at the list of items to cover, it does look long - so we can have a discussion if it looks like the exercise is going to get too complex. Since these are comparisons (and return booleans), it might be fun to do an extension on the story for bools that we have here: Ghost Gobble Arcade Game -- but you can always come up with your own story 😄 , or you can also use one from this list: exercise stories.

Thanks again for volunteering!

@BethanyG BethanyG self-assigned this Dec 11, 2020
@Limm-jk
Copy link
Contributor

Limm-jk commented Dec 12, 2020

Thank you!
I'll get started as soon as you tell me.
Where can I get information about exercism's slacks?
I would appreciate it if you could tell me how to work in Slack.

@BethanyG
Copy link
Member

BethanyG commented Dec 12, 2020

Hi @Limm-jk! For Slack, I just need an email and I can send you an invite directly. Is the one on your GitHub profile OK to use? I will send an invite there, and we can change it later if you need to.

EDIT: Since invites need admin approval, and the admins are in GMT and CET, there will be a delay for Slack.

@BethanyG
Copy link
Member

@Limm-jk - also - it is ok to start writing now if you are eager to get started. I may not have the concept description written until tomorrow my time (I'm in Pacific time, so I am 17 hours behind you. 😆 ).

@Limm-jk
Copy link
Contributor

Limm-jk commented Dec 12, 2020

Hi @Limm-jk! For Slack, I just need an email and I can send you an invite directly. Is the one on your GitHub profile OK to use? I will send an invite there, and we can change it later if you need to.

EDIT: Since invites need admin approval, and the admins are in GMT and CET, there will be a delay for Slack.

Good!
I added e-mail in my profile.
Thanx XD

@BethanyG BethanyG transferred this issue from exercism/v3 Jan 28, 2021
@BethanyG BethanyG changed the title [Python] Implement new Concept Exercise: comparisons [V3] Implement new Concept Exercise: comparisons Jan 28, 2021
@BethanyG BethanyG added this to the First 22 Concept Exercises Due for V3 milestone Jan 29, 2021
@github-actions
Copy link
Contributor

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

@BethanyG BethanyG modified the milestones: First 22 Concept Exercises Due for V3, New V3 Concept Exercises Mar 31, 2021
@BethanyG BethanyG removed this from the New V3 Concept Exercises milestone May 21, 2021
@BethanyG
Copy link
Member

Will be closing this issue, since PR #2420 completes this. Any edits/additions/re-writes will be noted under a different issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants