I started working through the 100 Days of Code course of Udemy last February, and I’m in the home stretch. I’m on the final lessons, which are really just prompts for projects. No hand holding, just a brief description of the goal. I recently finished a tkinter GUI program, the goal of which was to enable adding text watermarks.
I took a few liberties–mainly, I made it possible to layer a png on top of the background. It was a really fun project and quickly grew more complicated than I expected it to. I got some hands on experience with the Single Responsibility Principle, as I started off doing everything in my Layout class.
Eventually, I moved all the stuff that actually involved manipulating the Image objects to an ImageManager class. I feel like I could have gotten even more granular. That’s one thing I would love to get some feedback on. How would a more experienced programmer have architected this program?
Anyway, I guess this preamble is long enough. I’m going to leave a link to the repository here. I would have so much appreciation for anyone who took the time to look at the code, or even clone the repo and see if my instructions for getting it to run on your machine work.
def path_is_valid(path: Path) -> bool: if not path.exists(): return False return True
There’s no reason for this function to exist. Can you see why?
The good old if false return true
If not true return false
Not that the semantics matter in this case, NOT operator exists for a reason
Besides the duplication of standard code, I see this kind of mistake all the time. If your code can be reduced to “return path.exists” it’s an alias that shouldn’t be there.
bool(path.exists())