Add py in your code tag for better readability and visibility, it will look like below.
# This is our "sticker" (decorator)
defsay_hi(func):defnew_toy():print("Hi!")func()# The original toy still works
returnnew_toy# This is our toy (function)
@say_hi# Slap the sticker on!
deftalk():print("I’m a robot toy!")# Play with the toy
talk()
Calling say_hi() inside talk() works only once. If you require the feature in say_hi(), you need to repeat it in other functions. Decorators allow yoy to just define it once and use it repeatedly
Je suis un développeur Python passionné, spécialisé dans le développement de solutions logicielles innovantes et robustes. Avec une maîtrise approfondie de Python, je me distingue par sa capaci
Tech leader with a heart for service, a joyful spirit, and a knack for teaching 📚. Driven by curiosity 🔍 and guided by faith ✨, I bring a dash of humor 😄 to every challenge.
Hi Mahmoud EL-kariouny,
Good work.
Add py in your code tag for better readability and visibility, it will look like below.
Hi, Ramkumar
Thank you for your comment and suggestion.
Yes, it will be very helpful and cool 😎
But I don't know how to add py to my code😥🙄 because I know much in the mark down language
include space py after initial code marker, like
‘’’ py
Thank a lot bro 🤗, I updated the post
I hope you see it well now I learned new thing from you thank again 😎
Hi Mahmoud EL-kariouny,
No problem, we're here to help each other.
Yes, it looks great now.
Regards,
Ram
Yes, we here to help each other Ram
Nice to meet you
Be safe
Mahmoud
why not just call say_hi inside the talk() function, why use decorators? are there any special benefits?
Calling say_hi() inside talk() works only once. If you require the feature in say_hi(), you need to repeat it in other functions. Decorators allow yoy to just define it once and use it repeatedly
Thank you for your explanation 🤗😊😎
I hope it's clear now for you
Great explanation
Thank you 🤗😊😎
That's awesome 👌
Thank you 🤗😊😎
This is great analogy. Great article 👏
Thank you 🤗😊😎
Thanks for the simple and entertaining explanation, Mahmoud 👍🏻
It's my pleasure 😎
Thank you for your comment 🤗😊
How to use a main function with parameters
I'm sorry 🙏 but I don't understand your question 🙋
The quality of product surpassed my expectations!
Thank you 🤗😊😎