Advance Python-Decorators Indepth Implementation

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

КОМЕНТАРІ • 53

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

    Thanks a lot Krish, I watched 10 different videos on this concept and struggled to understand it. However, after finding your video, the explanation finally made sense and I was able to grasp the concept clearly.

  • @asehacha356
    @asehacha356 2 роки тому +3

    I have watch several u-tube videos on decorators & got more confused. You just made my day because I now clearly understand decorators. Excellent job!

  • @bharatkori659
    @bharatkori659 11 місяців тому +2

    These videos needs to go viral ,explained in such a beautifull way.

  • @mustakimsayyed5641
    @mustakimsayyed5641 2 роки тому +1

    Finally after a month got this point cleared...Thnks Krish

  • @broswhoknowstuff
    @broswhoknowstuff 3 роки тому +2

    Krish , excellent lessons! Than you for your hard work! I learned a lot here. It made me think. If I may so boldly add some additional logic to your great lecture on the copying of function's. I think Python's `concept of scope` is also an important topic to touch on when explaining function copying. Scope's are created only at function invocation( execution or call) and names are either "in scope" or "out-of-scope". I defined the welcome( ) function and using the following two assignment's: wel = welcome( ) and wel = welcome. The first assignment assigns a function call value. The later, only the function definition. NOTE: In either assignment's, the variable that is used reference's the exact same memory location of the defined function. ( I also use both the print and return statement's.) In the first assignment [ wel = welcome( ) ] , I use the print statement and the prints to standard output on the call to welcome( ). Now for function copying, and still using the print statement, I assign the variable 'wel' to 'welcome( )'. If I try to run "wel( )" I get `TypeError: 'NoneType' object is not callable `. "None" is also returned if you try to print the variable - 'wel' because there is no 'name' value given for any existing variable in the function's scope, only a print statement. If I instead use a 'return` statement instead, the returned 'value" is stored in the memory location of the welcome( ) function. The later method: `wel = welcome` (without parentheses ) copies the welcome ( ) function definition AND it's function body to "wel". Big Note here: the welcome( ) function is not executed at assignment! Now when you execute, wel( ), you get the string value. This is because the variable 'wel' is able to reference the body of the welcome( ) function in the global scope and invoke it , which 'wel( )' runs and creates it's local scope at the invocation for the value returned by the print statement. Am I close?

  • @govindsingh2724
    @govindsingh2724 3 роки тому +2

    Yesterday i was searching for closure , i got various videos but not satisfied. Finally , i get this one. Thank you sir🙏🏻

    • @M0N0T1C0L0URS
      @M0N0T1C0L0URS 3 роки тому +2

      So you could say... That Kris Naik gave you closure?

    • @govindsingh2724
      @govindsingh2724 3 роки тому

      You may say this , because he gave me exact explanation.

  • @ShukyPersky
    @ShukyPersky Рік тому +1

    Hi Krish. This is an appropriate opportunity to say thanks for your great videos and thank you for the good work you are making.
    I would like to comment regarding this video (time- 2:50)
    wel = welcome() - is NOT a function copy, it is a function invocation
    wel = welcome - creates a new reference to a function
    As you are an appreciated professional, may be I didn't follow your exact meaning. Can you please clarify? Thanks

  • @prakharakumar17
    @prakharakumar17 3 роки тому +1

    Great work Sir,
    Your teaching method is very persuasive and I'm following 12 days of python for ML.
    Thank you !!

  • @lalitharavichandran4015
    @lalitharavichandran4015 Рік тому

    You explain so well. I understand well and I am learning out of interest. Keep going!

  • @susmitvengurlekar
    @susmitvengurlekar 3 роки тому

    Checking out the cell no helps in debugging bugs of non executions of cells (variable not found), using variables which have been initialised somewhere else, I don't need to advise this, but keep calm, don't get tense, you are doing a great work

  • @gopinathrajamanickam9475
    @gopinathrajamanickam9475 3 роки тому

    Great Job Krish, Closure is something I never used as a terminology and decorators were always a black box until now. I liked the logical building blocks in your teaching method. I think function copy you mentioned does not copy the function as such, the variable wel simply stores the result from the earlier execution of welcome() . Correct me if I am wrong.

  • @9994392975
    @9994392975 3 роки тому

    Wonderful. This is what am exactly looking for decorator and clouser. Thank you Krish.

  • @dikshagupta3276
    @dikshagupta3276 2 роки тому

    Mind blowing explanation clear all Doubts thanku 🙏

  • @hinata6657
    @hinata6657 2 роки тому

    Amazing Video! Best explanation of decorators so far! Thank You

  • @g.jothilakshmikarthi6917
    @g.jothilakshmikarthi6917 2 роки тому

    The way you explained is very good to understand easy bro excellent

  • @susmitvengurlekar
    @susmitvengurlekar 3 роки тому +5

    You meant to code wel = welcome to demonstrating function copy right? Instead of wel = welcome() , which will just assign to wel whatever welcome() returns

  • @kingpanthom
    @kingpanthom 3 роки тому +3

    wel= welcome() actually copy the string to the variable wel and not the function. you did not call wel as function is called like wel(). The correct syntax to copy a function is wel = welcome without brackets.

    • @thegeekb0y
      @thegeekb0y 2 роки тому +1

      I was thinking the same too!

  • @nurulkarim1416
    @nurulkarim1416 2 роки тому

    you made it easier to understand and it's great .

  • @ittecheval1868
    @ittecheval1868 3 роки тому

    Closure mean, a function returned by another function and that returned function still have access to its sourrended variables where it is defined.

  • @rishabhkumar-qs3jb
    @rishabhkumar-qs3jb 3 роки тому

    Amazing video, explanation is awesome, I was always confused about decorator. Got it now :)

  • @kandukurivaishnavi4492
    @kandukurivaishnavi4492 Рік тому

    you are amazing krish

  • @abdullahshaikh7254
    @abdullahshaikh7254 3 роки тому

    Wow amazing
    I like the way you are teaching
    Thank you sir

  • @vigneshkumarramesh4834
    @vigneshkumarramesh4834 2 роки тому

    thank you very much, excellent explanation!!!

  • @lokeshpatel5018
    @lokeshpatel5018 3 роки тому +1

    Thanks Krish, I just want to know what will be the type of 'wel' in function copy case. From my understanding it would be str() not function. as we've stored return value from function welcome and then stored to 'wel'. But if we remove the parentheses while calling that will assign the function object to 'wel'. Correct me If I'm missing anything here.

    • @sujitsahoo3081
      @sujitsahoo3081 2 роки тому

      exactly. Even i just got confused and later realized this.

  • @ghazalehsaffori1014
    @ghazalehsaffori1014 3 роки тому +1

    Thank you 🙏🏻 it’s very helpful

  • @keshav9759
    @keshav9759 2 роки тому

    Sir i had a confusion at 6:19,
    i wanted to know when main_welcome() was called, which of the below described steps initiated:
    1. when main_welcome() was called, then return sub_welcome_class() line initiated which then called the sub_welcome_class() function, which the printed the following lines.
    2. Or any explanation which you would tell or say in modification of my explanation.

  • @kajalverma6910
    @kajalverma6910 2 роки тому

    According to me answer of your question: " after delete the function "welcome" is wel give the output or not" so my answer is no bcoz wel doesn't have any reference of that function so it doesn't give an output

  • @MrSmarthunky
    @MrSmarthunky 3 роки тому +3

    Thank you. In one of the data science interviews, I was asked - where would you use decorators?

    • @faezakamran3793
      @faezakamran3793 3 роки тому +6

      When we need a common functionality at several places. For instance, let's say there's a function square(), and there are let's suppose 5 other functions calling this square() function. In that case, you can make the square() function a decorator because it is being used in other 5 functions.

  • @user-or7ji5hv8y
    @user-or7ji5hv8y 3 роки тому

    Really good explanation

  • @austinmark242
    @austinmark242 3 роки тому +1

    Powli muthee

  • @sam_satish
    @sam_satish 3 роки тому

    Sir, for a college student what is more important taking internships or working on various data sets and improvising the topics

  • @sauravmehare9034
    @sauravmehare9034 3 роки тому +3

    Sir, I guess for the decorators we need to use " return sub_ welcome_class" instead of "return sub_welcome_class()"

    • @shaswatsood4595
      @shaswatsood4595 3 роки тому

      if we "return sub_welcome_class" it will give the object address

  • @ibadkhan481
    @ibadkhan481 2 роки тому

    loved it

  • @sarikavaidya6681
    @sarikavaidya6681 2 роки тому

    superb well done

  • @divyanshidixit352
    @divyanshidixit352 3 роки тому

    Great Content..😃

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

    You forgot parameters passing in decorators

  • @info_man
    @info_man Рік тому

    Now i understand where is @decorater the function just after it will pass as parameter

  • @kartiksharma-yw7qf
    @kartiksharma-yw7qf 3 роки тому +2

    sir, any update about data science 15-month course by ineuron.

  • @jagadeeshabburi570
    @jagadeeshabburi570 3 роки тому

    For me non type object error appeared after creating decorator

  • @VivekKumar-up8hb
    @VivekKumar-up8hb 3 роки тому

    during your session you missed one bracket and it did not threw any error, any specific reason??
    ### Closures & initial Decorators
    def main_welcome(func):

    def sub_welcome_class():
    print("Welcome To Krish Naik UA-cam Channel")
    print(func([1,2,3,4,5,6])) #bracket missed over here
    print("Please subscribe Krish channel")
    return sub_welcome_class()

  • @thedoruk724
    @thedoruk724 3 роки тому +1

    Sir I am beginner suggest me how to start. I know basic python and data visualization.

  • @disneysful
    @disneysful 3 роки тому

    Difficulty in understanding and u missed some points

  • @garyzhai9540
    @garyzhai9540 2 роки тому

    I like your hard work, unfortunately from my personal point of perspective, it is rather confusing the way you elaborate the concept of Decorator in Python.

  • @wellwhatdoyakno6251
    @wellwhatdoyakno6251 2 роки тому

    it's going to get deleted.