Vote count:
0
I'm working through exercises at Exercism.io and I don't understand one of the exercises. My task is to write a small module that will be imported at runtime.
The code below is part of the exercise, and neither Allergies or is_allergic_to are defined in the test file. It is up to me to define them in my module.
def test_has_the_right_allergies(self): allergies = Allergies(5) self.assertTrue(allergies.is_allergic_to('eggs'))
I'm really not looking for a solution, as much as simple guidance on what a good programmer sees, and if it's true that I should approach the solution with a class and method, or just two functions with "method-capable" object (whatever THAT might be).
As a hobbyist programmer, I'm having trouble understanding the syntax. I read
is_allergic_toas a method, but I don't know what type of object is being returned by the call toAllergies()Essentially, does the code imply that I create a ClassAllergiesthat has a methodis_allergic_to?
Python: Does this code imply a class and method "relationship?"
Aucun commentaire:
Enregistrer un commentaire