log dekoratör örneği 1

This commit is contained in:
Mert Gör ☭ 2023-08-04 18:46:25 +03:00
parent 28a8352a96
commit 6d2acb63f1
No known key found for this signature in database
GPG Key ID: 2100A876D55B39B9
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import datetime as dt
def mylog(f):
file = open('logfile.txt', 'w')
def log():
file.write('function called at ' + str(dt.datetime.now()) + '\n')
f()
return log
@mylog
def foo():
print('foo')
foo()
foo()
foo()