36
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]

I've seen two approaches which I'm going to post in the comments to see which one is considered best. Feel free to suggest others.

you are viewing a single comment's thread
view the rest of the comments
[-] [email protected] 7 points 1 year ago

This, but, with DatabaseConnection being a singleton, and preventing multiple enter clauses.

You can ensure it's a singleton by modifying how a new object is built, by overriding the new dunder method. If an instance exists, return that, otherwise create a new one.

this post was submitted on 14 Jul 2023
36 points (100.0% liked)

Python

6231 readers
2 users here now

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

📅 Events

October 2023

November 2023

PastJuly 2023

August 2023

September 2023

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

founded 1 year ago
MODERATORS