A suggestion that comes to me to improve the code cleanliness and how to work with it.
def get_vaccine_by_identifier(self, identifier):
"""Gets a vaccine by the identifier in the JSON file"""
for vaccine in self._known_vaccine_list:
if vaccine.vaccine_identifier == identifier:
return vaccine
raise ValueError("Unknown vaccine")
If we pass self._known_vaccine_list as a dict() we could just use
def get_vaccine_by_identifier(self, identifier):
"""Gets a vaccine by the identifier in the JSON file"""
if vaccine.vaccine_identifier in VACCINE_DICTIONARY:
return True, vaccine
else:
raise ValueError("Unknown vaccine")
And dictionaries can be changed to JSON whenever we want, but we gain speed and stability when working with them.
It's a suggestion, maybe it has a dark side that I don't see.
Let's not forget that dictionaries can also be serialised, stored and loaded from main memory to persistent memory.
Hi,
Good afternoon,
A suggestion that comes to me to improve the code cleanliness and how to work with it.
If we pass
self._known_vaccine_list
as adict()
we could just useAnd dictionaries can be changed to JSON whenever we want, but we gain speed and stability when working with them.
It's a suggestion, maybe it has a dark side that I don't see.
Regards