Advance Python-Decorators Indepth Implementation

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ธ.ค. 2024

ความคิดเห็น • 55

  • @bharatkori659
    @bharatkori659 ปีที่แล้ว +2

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

  • @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!

  • @nisha7100
    @nisha7100 4 หลายเดือนก่อน +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.

  • @mustakimsayyed5641
    @mustakimsayyed5641 3 ปีที่แล้ว +1

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

  • @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.

  • @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?

  • @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!

  • @hinata6657
    @hinata6657 3 ปีที่แล้ว

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

  • @ShukyPersky
    @ShukyPersky 2 ปีที่แล้ว +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

  • @dikshagupta3276
    @dikshagupta3276 2 ปีที่แล้ว

    Mind blowing explanation clear all Doubts thanku 🙏

  • @9994392975
    @9994392975 3 ปีที่แล้ว

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

  • @nurulkarim1416
    @nurulkarim1416 2 ปีที่แล้ว

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

  • @g.jothilakshmikarthi6917
    @g.jothilakshmikarthi6917 2 ปีที่แล้ว

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

  • @kandukurivaishnavi4492
    @kandukurivaishnavi4492 2 ปีที่แล้ว

    you are amazing krish

  • @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

  • @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.

  • @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

  • @rishabhkumar-qs3jb
    @rishabhkumar-qs3jb 3 ปีที่แล้ว

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

  • @vigneshkumarramesh4834
    @vigneshkumarramesh4834 2 ปีที่แล้ว

    thank you very much, excellent explanation!!!

  • @SatyaPrakashBehera-v5q
    @SatyaPrakashBehera-v5q 24 วันที่ผ่านมา

    I didn't get the function copy. You are basically saving the return value of welcome in wel, so even if you delete the function wel is going to have the value. Because after executing the function you are deleting it.

  • @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.

  • @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!

  • @ghazalehsaffori1014
    @ghazalehsaffori1014 3 ปีที่แล้ว +1

    Thank you 🙏🏻 it’s very helpful

  • @abdullahshaikh7254
    @abdullahshaikh7254 3 ปีที่แล้ว

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

  • @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.

  • @divyanshidixit352
    @divyanshidixit352 3 ปีที่แล้ว

    Great Content..😃

  • @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.

  • @ibadkhan481
    @ibadkhan481 2 ปีที่แล้ว

    loved it

  • @austinmark242
    @austinmark242 3 ปีที่แล้ว +1

    Powli muthee

  • @jagadeeshabburi570
    @jagadeeshabburi570 3 ปีที่แล้ว

    For me non type object error appeared after creating decorator

  • @sarikavaidya6681
    @sarikavaidya6681 2 ปีที่แล้ว

    superb well done

  • @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

  • @user-or7ji5hv8y
    @user-or7ji5hv8y 3 ปีที่แล้ว

    Really good explanation

  • @kartiksharma-yw7qf
    @kartiksharma-yw7qf 3 ปีที่แล้ว +2

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

    • @krishnaik06
      @krishnaik06  3 ปีที่แล้ว +1

      Check ineuron channel

  • @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.

  • @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

  • @info_man
    @info_man ปีที่แล้ว

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

  • @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

  • @thedoruk724
    @thedoruk724 3 ปีที่แล้ว +1

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

  • @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 TH-cam Channel")
    print(func([1,2,3,4,5,6])) #bracket missed over here
    print("Please subscribe Krish channel")
    return sub_welcome_class()

  • @anandesh
    @anandesh 9 หลายเดือนก่อน

    You forgot parameters passing in decorators

  • @SatyaPrakashBehera-v5q
    @SatyaPrakashBehera-v5q 24 วันที่ผ่านมา

    def welcome(func):
    def sub_class():
    print("Hello World")
    func()
    return sub_class
    @welcome
    def closing():
    print("Execution Ends")
    wel = closing
    del welcome
    del closing
    wel()

  • @disneysful
    @disneysful 3 ปีที่แล้ว

    Difficulty in understanding and u missed some points

  • @garyzhai9540
    @garyzhai9540 3 ปีที่แล้ว

    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.