11 Jul
2023
11 Jul
'23
5:58 a.m.
Am 10.07.2023 um 23:45 schrieb Ulrich Goebel <ml@fam-goebel.de>:
Ist das ein gutes, "pythonisches" Vorgehen? Oder gibt es eine elegantere Möglichkeit?
Hmm, kennst du das Repository-Pattern schon? Das ist so der übliche Weg, wenn man die Datenhaltung wegabstrahieren möchte: https://www.cosmicpython.com/book/chapter_02_repository.html
Unschön bleibt aus meiner Sicht, dass der DB-Konnektor nur über eine Funktion zugänglich ist, also DB(). Schöner wäre DB, also eine "Zustand des Moduls" - aber das gibt es wohl nicht? So
Klar, das geht auch. Aber Attribute von Modulen sind halt für alle gleich, d.h. wenn man das ändern sollte, ändert man es für alle, die es benutzen. Viele Grüße Jochen