Closed DavidGerva closed 3 years ago
@BethanyG, please I would like to have a review to this issue. Not sure about (a lot of things and):
@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??
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.
Sounds good to me!
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.
Re-edited with details described above. Chime in if this looks strange..
Really nice. I'm glad it was useful to raise the doubts.
Hello! Is this issue in progress? If not, can I take up the issue?
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!
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.
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.
@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. 😆 ).
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
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.
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
boolean
valuesTrue
andFalse
is
andis not
are for checking an objects identity only==
and!=
compare both the value & type of an object.==
and!=
for certainbuilt-in
types (such as numbers), or for standard library types like decimals, and fractions to allow comparison across and within type.str
) and binary sequences (bytes
&byte array
) cannot be directly compared.built-in
sequence types (list
,tuple
,range
) andbuilt-in
collection types (set
,dict
)None
,NotImplemented
(comparing either should use identity operators and not equality operators because they are singleton objects) andNaN
(NaN is never==
to itself)==
,>
,<
,!=
with numeric types==
,>
,<
,!=
with non-numeric typesis
andis not
to check/verify identityOut of scope
__lt__
,__le__
,__ne__
,__ge__
,__gt__
==
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 genericobject
is used.__eq__()
dunder method on a specific object to customize comparison behavior.set operations
Concepts
==
,>
,<
,!=
is
andis not
built-in
typesPrerequisites
basics
bools
dicts
lists
sets
strings
tuples
numbers
iteration
Resources to refer to
Hints
Concept Description
(a variant of this can be used for the
v3/languages/python/concepts/<concept>/about.md
doc and this exercisesintroduction.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.