Learn Python DECORATORS in 7 minutes! 🎊

Поділитися
Вставка
  • Опубліковано 22 гру 2024

КОМЕНТАРІ • 54

  • @BroCodez
    @BroCodez  6 місяців тому +6

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

  • @michellguzelgul4267
    @michellguzelgul4267 4 місяці тому +5

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

  • @NoName-is3tu
    @NoName-is3tu 5 місяців тому +12

    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 5 місяців тому +3

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

  • @PriscaNetsaiTingiMututsva
    @PriscaNetsaiTingiMututsva 23 дні тому

    Bro Code you taught me from zero to hero without knowing anything about coding thank you with your videos could make more about machine learning using python for beginners

  • @StoicismAspects
    @StoicismAspects 5 місяців тому +1

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

  • @alexn7208
    @alexn7208 3 місяці тому +1

    the best video for decorators finally i got it bro thanks

  • @lachaisegaming8263
    @lachaisegaming8263 5 місяців тому +1

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

  • @Ann-pj7ie
    @Ann-pj7ie 4 місяці тому

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

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

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

  • @sameerroshan9542
    @sameerroshan9542 4 місяці тому +3

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

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

    Nice video Bro 👍

  • @hoperight5280
    @hoperight5280 10 днів тому

    Well, bro, to be honest, English is not my first language. As a matter of fact, I understand it easily, even though I watched some videos that are recorded in my native language and couldn't understand it. Appreciate it!

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

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

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

    Great explanation!

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

    Thanks bro very helpful😀

  • @mpkrass
    @mpkrass 19 днів тому

    Good explanation of decorators though noting that decorators can also take arguments. I was hoping for a clear explanation on setting those up. Although I get that might be challenging to cover in 7 minutes

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

    I have a question, but before I gotta say you're amazing man!! You don't care about the complex terms and you explain it so simply, and you also talk about why every piece is there with reasonable examples. I could have gone to documentaries and spent a good hour on them but here I am with a solid understanding of the basics of the topic within 7 minutes.
    Question is, what do we need the func for? Is it a representative of the get_ice_cream function, or any function that we add this Decorator to?

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

      Yeah its just an argument. So any function you add the decorator to will be passed to it. Its not specific to the get_ice_cream function

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

      @@dankwabismark2598 thank you very much

  • @morningwood3938
    @morningwood3938 3 місяці тому

    Bro Code. You are the best.

  • @manjuch3345
    @manjuch3345 3 місяці тому +1

    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

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

      The add_sprinkles decorator is called first. Then within this decorator, it calls the add_fudge decorator. Eventually the base function, get_ice_cream is called. You can think like this, the add_sprikles extends the add_fudge, which extends the get_ice_cream function

  • @0ZANGETSUFLASH0
    @0ZANGETSUFLASH0 3 місяці тому

    wow ur god at explaining

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

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

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

      See the python full course this are arguments and key arguments

  • @dendell8860
    @dendell8860 5 місяців тому

    Doubt cleared.. Thank you Sir

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

    I am still having difficulties understanding this topic.
    and more recommended videos?

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

    thanks ! i love u

  • @Johnvids-g3o
    @Johnvids-g3o 2 місяці тому +10

    I liked my own comment

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

    Do more java videos, make games

  • @johnneisler6552
    @johnneisler6552 5 місяців тому

    You are the best teacher ive ever had

  • @Pradeep-mh9ui
    @Pradeep-mh9ui 2 місяці тому

    Thanks!

  • @Johnvids-g3o
    @Johnvids-g3o 2 місяці тому +2

    Who likes icecream🍨?
    👇

  • @airslav
    @airslav 4 місяці тому

    bro thank you very much🙏

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

    Dude you are an actual bro

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

    I played it at 2x speed, such that I got python decorators in 3.5 minutes.

  • @JafoorK
    @JafoorK 5 місяців тому

    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 5 місяців тому

    W work

  • @Diamond_Hanz
    @Diamond_Hanz 5 місяців тому

    bro code is life

  • @swkratis6787
    @swkratis6787 5 місяців тому

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

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

      Calling through decorators using @at top

    • @PriscaNetsaiTingiMututsva
      @PriscaNetsaiTingiMututsva 23 дні тому

      Because it's decorator l think you must learn Object Oriented programming before learning decorators because this topic it's more advanced

  • @georgemouxios8248
    @georgemouxios8248 4 місяці тому +1

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

  • @BunrithViwatthanak
    @BunrithViwatthanak 5 місяців тому

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

  • @vibingowsic2338
    @vibingowsic2338 5 місяців тому

    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.

  • @kallapallisai9959
    @kallapallisai9959 5 місяців тому

    make a video on mongoDB plz sir