Advance Python-Decorators Indepth Implementation

  Рет қаралды 39,562

Krish Naik

Krish Naik

Күн бұрын

Пікірлер: 55
@bharatkori659
@bharatkori659 Жыл бұрын
These videos needs to go viral ,explained in such a beautifull way.
@asehacha356
@asehacha356 2 жыл бұрын
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 5 ай бұрын
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 жыл бұрын
Finally after a month got this point cleared...Thnks Krish
@govindsingh2724
@govindsingh2724 4 жыл бұрын
Yesterday i was searching for closure , i got various videos but not satisfied. Finally , i get this one. Thank you sir🙏🏻
@M0N0T1C0L0URS
@M0N0T1C0L0URS 4 жыл бұрын
So you could say... That Kris Naik gave you closure?
@govindsingh2724
@govindsingh2724 4 жыл бұрын
You may say this , because he gave me exact explanation.
@prakharakumar17
@prakharakumar17 3 жыл бұрын
Great work Sir, Your teaching method is very persuasive and I'm following 12 days of python for ML. Thank you !!
@guyswhoknowstuff
@guyswhoknowstuff 3 жыл бұрын
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?
@ShukyPersky
@ShukyPersky 2 жыл бұрын
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
@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
@9994392975
@9994392975 3 жыл бұрын
Wonderful. This is what am exactly looking for decorator and clouser. Thank you Krish.
@susmitvengurlekar
@susmitvengurlekar 4 жыл бұрын
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
@g.jothilakshmikarthi6917
@g.jothilakshmikarthi6917 2 жыл бұрын
The way you explained is very good to understand easy bro excellent
@rishabhkumar-qs3jb
@rishabhkumar-qs3jb 3 жыл бұрын
Amazing video, explanation is awesome, I was always confused about decorator. Got it now :)
@dikshagupta3276
@dikshagupta3276 2 жыл бұрын
Mind blowing explanation clear all Doubts thanku 🙏
@kingpanthom
@kingpanthom 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 жыл бұрын
I was thinking the same too!
@susmitvengurlekar
@susmitvengurlekar 4 жыл бұрын
You meant to code wel = welcome to demonstrating function copy right? Instead of wel = welcome() , which will just assign to wel whatever welcome() returns
@vrushabhjinde683
@vrushabhjinde683 2 жыл бұрын
Yess
@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.
@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.
@abdullahshaikh7254
@abdullahshaikh7254 4 жыл бұрын
Wow amazing I like the way you are teaching Thank you sir
@gopinathrajamanickam9475
@gopinathrajamanickam9475 4 жыл бұрын
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.
@kandukurivaishnavi4492
@kandukurivaishnavi4492 2 жыл бұрын
you are amazing krish
@ghazalehsaffori1014
@ghazalehsaffori1014 4 жыл бұрын
Thank you 🙏🏻 it’s very helpful
@vigneshkumarramesh4834
@vigneshkumarramesh4834 2 жыл бұрын
thank you very much, excellent explanation!!!
@lokeshpatel5018
@lokeshpatel5018 3 жыл бұрын
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.
@SatyaPrakashBehera-v5q
@SatyaPrakashBehera-v5q Ай бұрын
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.
@user-or7ji5hv8y
@user-or7ji5hv8y 4 жыл бұрын
Really good explanation
@MrSmarthunky
@MrSmarthunky 4 жыл бұрын
Thank you. In one of the data science interviews, I was asked - where would you use decorators?
@faezakamran3793
@faezakamran3793 3 жыл бұрын
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.
@austinmark242
@austinmark242 4 жыл бұрын
Powli muthee
@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
@divyanshidixit352
@divyanshidixit352 3 жыл бұрын
Great Content..😃
@kartiksharma-yw7qf
@kartiksharma-yw7qf 4 жыл бұрын
sir, any update about data science 15-month course by ineuron.
@krishnaik06
@krishnaik06 4 жыл бұрын
Check ineuron channel
@anandesh
@anandesh 9 ай бұрын
You forgot parameters passing in decorators
@sarikavaidya6681
@sarikavaidya6681 2 жыл бұрын
superb well done
@sauravmehare9034
@sauravmehare9034 4 жыл бұрын
Sir, I guess for the decorators we need to use " return sub_ welcome_class" instead of "return sub_welcome_class()"
@shaswatsood4595
@shaswatsood4595 4 жыл бұрын
if we "return sub_welcome_class" it will give the object address
@info_man
@info_man Жыл бұрын
Now i understand where is @decorater the function just after it will pass as parameter
@sam_satish
@sam_satish 4 жыл бұрын
Sir, for a college student what is more important taking internships or working on various data sets and improvising the topics
@jagadeeshabburi570
@jagadeeshabburi570 3 жыл бұрын
For me non type object error appeared after creating decorator
@SatyaPrakashBehera-v5q
@SatyaPrakashBehera-v5q Ай бұрын
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()
@ibadkhan481
@ibadkhan481 2 жыл бұрын
loved it
@thedoruk724
@thedoruk724 4 жыл бұрын
Sir I am beginner suggest me how to start. I know basic python and data visualization.
@VivekKumar-up8hb
@VivekKumar-up8hb 4 жыл бұрын
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 KZbin Channel") print(func([1,2,3,4,5,6])) #bracket missed over here print("Please subscribe Krish channel") return sub_welcome_class()
@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.
Python Series- is Vs == Indepth Explanation- Boolean Evaluation
6:57
Class Variables And Class Methods In Python
9:49
Krish Naik
Рет қаралды 32 М.
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН
Ozoda - Alamlar (Official Video 2023)
6:22
Ozoda Official
Рет қаралды 10 МЛН
Sigma girl VS Sigma Error girl 2  #shorts #sigma
0:27
Jin and Hattie
Рет қаралды 124 МЛН
Python Decorators in 15 Minutes
15:14
Kite
Рет қаралды 457 М.
The Ultimate Guide to Writing Classes in Python
25:39
ArjanCodes
Рет қаралды 123 М.
Python Eval Function- Evaluating Python Expressions Dynamically
18:30
Advanced Python Series - Iterators Vs Generators
16:18
Krish Naik
Рет қаралды 55 М.
PLEASE Use These 5 Python Decorators
20:12
Tech With Tim
Рет қаралды 127 М.
Python Decorators: The Complete Guide
27:59
ArjanCodes
Рет қаралды 163 М.
Python dataclasses will save you HOURS, also featuring attrs
8:50
5 Useful Python Decorators (ft. Carberra)
14:34
Indently
Рет қаралды 110 М.
ССЫЛКА НА ИГРУ В КОММЕНТАХ #shorts
0:36
Паша Осадчий
Рет қаралды 8 МЛН