animal-facts-bot
animal-facts-bot copied to clipboard
Cleaning up the code.
Added opening files with context manager. Function in animalfacts.py simplified using elif statement. Fixed typo in README
@Jac08H I'm not clear on 'with'.
This will maintain all same functionality?
Yeah, it's just safer way to open files because it closes the file stream in all situations. For example, in your code the files would stay opened if it would throw any kind of exception.
https://docs.python.org/3/tutorial/inputoutput.html#reading-and-writing-files
Assuming conflicts can be sorted this is definitely worth pulling. “With” is worth doing on all your opens
@joel-g shall we take this one? The with opening method is definitely better, but you should check it to make sure it's all ok. I may not have the time. One for a rainy day :)