In meiner Klasse ich diese Methode geschrieben:Python Dekorateur meine Funktionskontrolle
def ts_prep(self, test_id):
ltouple =()
tab_lib = temp_library.objects.filter(main_id=test_id)
l1 = ["Settings", ""]
ltouple += (l1,)
if tab_lib.count() == 0: ltouple = (l1, ["", ""])
l = []
for r in tab_lib.iterator():
l.append(str(r.l_type))
l.append(str(r.l_val))
ltouple += (l,)
l = []
tslist = [x for x in ltouple]
return tslist
Wie könnte ich ein Dekorateur für meine Methode erstellen, die, wenn tab_lib Prüfung durchführen wenn Sie in allen Verfahren hinzuzufügen, die die gleiche Prüfung machen ?
ich versuche
def p_decorate(func):
def func_wrapper(test_id):
tab_lib = temp_library.objects.filter(main_id=test_id)
l1 = ["Settings", ""]
ltouple += (l1,)
if tab_lib.count() == 0: ltouple = (l1, ["", ""])
return ltouple
return func_wrapper
aber es scheint nicht
Vielen Dank im Voraus arbeiten
Was ist die Funktion tut und was haben Sie versucht, so weit? SO ist kein Code-Schreibdienst. – Ding