-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecorator.py
More file actions
33 lines (25 loc) · 740 Bytes
/
decorator.py
File metadata and controls
33 lines (25 loc) · 740 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class Article:
def show(self):
print('All Articles....')
class Login:
def check_login(self, username, password) -> bool:
if username == 'admin' and password == '1234':
return True
return False
def outer_login(func):
def inner_login(*args, **kwargs):
username = input('Username: ')
password = input('Password: ')
login = Login()
is_login = login.check_login(username, password)
if is_login:
func(*args, **kwargs)
else:
print('Wrong Username or Password!')
return inner_login
@outer_login
def show_all_articles():
articles = Article()
articles.show()
if __name__ == '__main__':
show_all_articles()