Learn Python DECORATORS in 7 minutes! 🎊

preview_player
Показать описание
# Decorator = A function that extends the behavior of another function
# w/o modifying the base function
# Pass the base function as an argument to the decorator

def add_sprinkles(func):
def wrapper(*args, **kwargs):
print("*You add sprinkles 🎊*")
func(*args, **kwargs)
return wrapper

def add_fudge(func):
def wrapper(*args, **kwargs):
print("*You add fudge 🍫*")
func(*args, **kwargs)
return wrapper

@add_sprinkles
@add_fudge
def get_ice_cream(flavor):
print(f"Here is your {flavor} ice cream 🍨")

get_ice_cream("vanilla")
Рекомендации по теме
Комментарии
Автор

# Decorator = A function that extends the behavior of another function
# w/o modifying the base function
# Pass the base function as an argument to the decorator

def add_sprinkles(func):
def wrapper(*args, **kwargs):
print("*You add sprinkles 🎊*")
func(*args, **kwargs)
return wrapper

def add_fudge(func):
def wrapper(*args, **kwargs):
print("*You add fudge 🍫*")
func(*args, **kwargs)
return wrapper

@add_sprinkles
@add_fudge
def get_ice_cream(flavor):
print(f"Here is your {flavor} ice cream 🍨")

get_ice_cream("vanilla")

BroCodez
Автор

I had some doubts regarding this topic today...and you just clutched at right time and solved my problem...thank you bro code!

NoName-istu
Автор

bro you are the best programing teacher on the youtube bro i beg to say please make the complete react course from beginner to advance so it must be very helpful for those people who cannot afford expensive class or intuition...bro thankyou soo much once again....💓💓💐💐🤗🤗...

ujjwaljohn
Автор

didn't saw the time going, very helpful tutorial thx

lachaisegaming
Автор

This is the clearest explanation I have heard. Thank you.

michellguzelgul
Автор

I 100% thought the poop emoji was coming with fudge. Nice video!

fordayinlife
Автор

you made the concept very clear in simple way..thank you very much

Ann-pjie
Автор

Your every single video is useful & meaning full Thanks for the video Bro😃

Abdullo_
Автор

Hey bro. this is one of the topics I expected from you. Thanks man!

Greenbay-bnyk
Автор

What is the use of the word in parentheses(func)*?

mohamedcoufi
Автор

I have one doubt, when we call multiple decorators we are using the func() within the wrapper right.At that time, base function will calling 2 times or not

manjuch
Автор

Why do this and not call the function. Its a genuine question. Thanks to whoever responds

swkratis
Автор

why is it not calling func() per decorator when you have multiple decorators. Why isnt it printing "Here is your icecream" multiple times?

sameerroshan
Автор

Could someone let me know what these are used for? Like what can you do with it that you cannot do some other way?

TheMostCurryBoy
Автор

Hey bro! How is it going? Hope you are doing well. In this comment I am going to ask you about Android development tutorial in java.

Hi bro, I learned java from your tutorial. But there is a problem. When I got into android development, I got stuck. Can you please do a tutorial android with java.

vibingowsic
Автор

what happened to your old voice? change of mic? ( algorithm comment)

georgemouxios
Автор

we now don't even use Alt + ; anymore because it doesn't work. Now we use Windows Key + .(period)

BunrithViwatthanak
visit shbcf.ru