this post was submitted on 14 Jun 2024
31 points (100.0% liked)

Python

6405 readers
21 users here now

Welcome to the Python community on the programming.dev Lemmy instance!

📅 Events

PastNovember 2023

October 2023

July 2023

August 2023

September 2023

🐍 Python project:
💓 Python Community:
✨ Python Ecosystem:
🌌 Fediverse
Communities
Projects
Feeds

founded 1 year ago
MODERATORS
 

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.

Watermark GUI Repo

you are viewing a single comment's thread
view the rest of the comments
[–] tatterdemalion 8 points 5 months ago (2 children)
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?

[–] [email protected] 3 points 5 months ago (1 children)

The good old if false return true

[–] JackbyDev 2 points 5 months ago (1 children)
[–] [email protected] 1 points 5 months ago* (last edited 5 months ago)

Not that the semantics matter in this case, NOT operator exists for a reason

[–] [email protected] 3 points 5 months ago (1 children)

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.

[–] [email protected] 3 points 5 months ago

bool(path.exists())