Learn Python DECORATORS in 7 minutes! 🎊

Поділитися
Вставка
  • Опубліковано 7 вер 2024
  • 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")

КОМЕНТАРІ • 34

  • @BroCodez
    @BroCodez  2 місяці тому +1

    # 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")

  • @NoName-is3tu
    @NoName-is3tu 2 місяці тому +9

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

  • @ujjwaljohn1789
    @ujjwaljohn1789 2 місяці тому +2

    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....💓💓💐💐🤗🤗...

  • @lachaisegaming8263
    @lachaisegaming8263 Місяць тому +1

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

  • @michellguzelgul4267
    @michellguzelgul4267 26 днів тому

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

  • @Ann-pj7ie
    @Ann-pj7ie 29 днів тому

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

  • @Abdullo_1124
    @Abdullo_1124 2 місяці тому +1

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

  • @fordayinlife
    @fordayinlife 2 місяці тому +1

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

  • @morningwood3938
    @morningwood3938 4 дні тому

    Bro Code. You are the best.

  • @0ZANGETSUFLASH0
    @0ZANGETSUFLASH0 11 днів тому

    wow ur god at explaining

  • @AbelFikadu-lt1ei
    @AbelFikadu-lt1ei 2 місяці тому +1

    Thanks bro very helpful😀

  • @Greenbay-bn3yk
    @Greenbay-bn3yk 2 місяці тому

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

  • @a7md8762
    @a7md8762 2 місяці тому +2

    Nice video Bro 👍

  • @mohamedcoufi9873
    @mohamedcoufi9873 2 місяці тому +2

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

    • @ashimsarkar662
      @ashimsarkar662 2 місяці тому +1

      See the python full course this are arguments and key arguments

  • @airslav
    @airslav Місяць тому

    bro thank you very much🙏

  • @dendell8860
    @dendell8860 2 місяці тому

    Doubt cleared.. Thank you Sir

  • @swkratis6787
    @swkratis6787 2 місяці тому

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

  • @manjuch3345
    @manjuch3345 11 днів тому

    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

  • @TroddenAnimations
    @TroddenAnimations 2 місяці тому +1

    Do more java videos, make games

  • @UmairAhmad-911
    @UmairAhmad-911 2 місяці тому

    Dude you are an actual bro

  • @sameerroshan9542
    @sameerroshan9542 17 днів тому

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

  • @TheMostCurryBoy
    @TheMostCurryBoy Місяць тому

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

  • @RicksterTheTrickster12
    @RicksterTheTrickster12 2 місяці тому

    W work

  • @BunrithViwatthanak
    @BunrithViwatthanak 2 місяці тому

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

  • @johnneisler6552
    @johnneisler6552 2 місяці тому

    You are the best teacher ive ever had

  • @kallapallisai9959
    @kallapallisai9959 2 місяці тому

    make a video on mongoDB plz sir

  • @Diamond_Hanz
    @Diamond_Hanz 2 місяці тому

    bro code is life

  • @vibingowsic2338
    @vibingowsic2338 2 місяці тому

    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.

  • @georgemouxios8248
    @georgemouxios8248 28 днів тому

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