decorator

Run Settings
LanguagePython
Language Version
Run Command
def decorator(func): def wrap(*args, **kwargs): print('*********') func(*args, **kwargs) print('@@@@@@@@@@') return wrap @decorator def hai(*args, emo=':('): print(*args,"-----", emo) hai('i can pass parameter on decorator','121','usly','2222','serio','so long',':)') # Create an @authenticated decorator that only allows the function to run is user1 has 'valid' set to True: user1 = { 'name': 'Sorna', 'valid': True #changing this will either run or not run the message_friends function. } def authenticated(fn): # code here def wrap(*args, **kwargs): if args[0]['valid']: fn(*args, **kwargs) else: print('user is not authorized') return wrap @authenticated def message_friends(user): print('message has been sent') print(user1['name']) message_friends(user1)
Editor Settings
Theme
Key bindings
Full width
Lines