I just realized that you being physically present in the video makes such a big difference to how much attention I pay. There are tons of videos out there but your videos work for me because there is someone teaching and I can see them typing the code. The expressions and gestures also help with the learning, maybe subconsciously we understand better if knowledge transfer is backed by facial expressions. Thanks again for choosing to share your knowledge, for free!
@wolverine878334 жыл бұрын
The same I felt
@Dre2k074 жыл бұрын
The best is when he makes mistakes and you can see his reaction lol makes it more real
@_.sunnyraj._4 жыл бұрын
Me also for any video web cam is must
@iamniks4 жыл бұрын
totally agree ..
@shivaramakrishnans48804 жыл бұрын
Very very true...
@chrism37905 жыл бұрын
You missed the most important part of the whole thing. Using the @ syntax before the function we want to wrap is what makes decorators useful.
@HomerSimpsonian5 жыл бұрын
I had to watch another video that explains it to make me see that the way he explained it was also very good. I was just thrown off by the lack of the @ syntax.
@bakachelera4 жыл бұрын
I was waiting for the @ thing, or a part 2 of this too. anyway this was a good video. Subscribed.
@gayalkuruppu93874 жыл бұрын
Same here 😒 went to another video. But this one is really good too!
@obviouscreed4 жыл бұрын
Need the link for the other video, did not get this concept
@ritamchatterjee33074 жыл бұрын
what is this @ syntax all about, i dont know this can get any link please
@kamilkurzynowski38363 жыл бұрын
For those asking about the missing @, this guy actually explains what are decorators not how they are written. The syntax is unimportant if you don't know what is happening behind the scenes. The issue I observe with new programmers is that people are using stuff that they have no idea how is it working. I appreciate a great conceptual explanation.
@purplemonkeydishwasher52692 жыл бұрын
Yep. That would describe me. But Telusko threw in some really good information here. So basically the decorator is redefining where the 'div' object is pointing to in memory right?
@ranjeethstudio2483Ай бұрын
But I don't know how to use @syntax and why they use @wrap. It will be helpful if he do separate video on this
@liquidred25714 күн бұрын
So I think I agree with what @ranjeethstudio2483 is getting at, insofar as while yes, "The syntax is unimportant if you don't know what is happening behind the scenes." 1. because the video is trying to teach what a wrapper is, at the same time that it's trying to explain what a decorator is, the video is harder to follow. 2. because this video is trying to teach what a decorator is, he should teach what a decorator is in a traditional setting. I.e. "here's what a decorator will look like when you see it in code and how it works." 3. It's not unimportant if you actually want to use them in your code.
@kandasamymurugadas68384 жыл бұрын
You are the hero of students who are eager to learn coding but can't afford to go for tution ,even me.hands off to my guru
@GiovaniGalicia5 жыл бұрын
Ok, have to admit that this was one of the videos that was a little harder to grasp. I do get the main goal of decorators, but I am searching for more examples on how to use decorators. Your video was a great first start. Thank you!
@akashsuna51602 жыл бұрын
Try code with harry for this one than jump to telusko you will get the Idea. No offence i am not comparing these two channels they both have their own taste our main intention is to grasp the concept
@SpaceTimeBeing_2 жыл бұрын
@@akashsuna5160 don't promote that guy. India was humiliated 2 years ago during github's hacktoberfest because this moron misguided clueless people into participating in it. It was horrible thanks to him.
@liveinthemoment6218 Жыл бұрын
I am a postgraduate in electronics field. I thought programming would be difficult, but u made it as simple as that. You are a great teacher. I have been working as a lecturer since 8 yrs . I have never seen a person like u, who teaches with so much of energy and enthusiasms. I have to learn many things from u -way of teaching.etc......
@asishraz61734 жыл бұрын
yes, agreed with many viewers that Navin sir haven't used '@' in the whole explanation. But we all understood the concept of Decorators through his explanation, which most of the KZbinrs failed to explain.
@extraxt5 жыл бұрын
The best explanation I've seen so far. I'm a Python beginner (I work with Javascript).
@ThatGuyTheyareAfter4 жыл бұрын
Isn' this almost exactly like javascript's closures?
@kruthikahu9044 жыл бұрын
your teaching is just awesome sir! I have seen blockchain videos and now am learning python just by seeing your python videos. its just wow! great work sir. Thank You.
@divyasinha82044 жыл бұрын
Sir why did we use ‘return inner’ in the end, I didn’t understand. Because ‘return func(a,b)’ is already doing the work of calling div(a,b) right? Then what is the use of return inner?
@uges_expo3 жыл бұрын
I just realized that you being physically present in the video makes such a big difference to how much attention I pay. There are tons of videos out there but your videos work for me because there is someone teaching and I can see them typing the code. The expressions and gestures also help with the learning, maybe subconsciously we understand better if knowledge transfer is backed by facial expressions. Thanks again for choosing to share your knowledge, for free!
@mdsadaquathussain3075 жыл бұрын
Sir i saw the whole ad so that you get the reward😊😀
@_.sunnyraj._4 жыл бұрын
🤣
@mohitbendale82294 жыл бұрын
just click the add and close it. It works on a cost per click. It won't do anything if you just watch the add.
@SaFFire123x4 жыл бұрын
@Dharmesh Rajan your mindset is what I call 'chutiya' mindset. Clearly, you were never taught to give back. Tutors like Navin Reddy are teaching for free and can't you even watch a 30s ad for him? Nobody is asking how to get rid of ads here. @mohit and @MD are talking about supporting the video creator by watching ads. Get lost with your tip that no-one asked for.
@SaFFire123x4 жыл бұрын
@Dharmesh Rajan Hey! Take it easy. I was only discouraging 'greedy mindset'. It's not just 5 minutes but 5000 hours of experience, pre and post processing that KZbinrs put into their videos. So the feeling of being morally obliged to give back should come from within. That's what I wanted to imply. No intention of hurting anyone. I felt like you were publicising the use of vanced on a completely irrelevant and unnecessary thread. Glad that you deleted it. Peace ✌️ and happy learning :)
@aerospacebriefcase22903 жыл бұрын
@Stick / tutorials Thanks mate
@timtech93612 жыл бұрын
Decorators are one of things added to the list of "Never Use Unless you Want to Ruin Your Program". Tread carefully.
@liquidred25714 күн бұрын
Since nobody wants to " 'Ruin [their] Program' " can you elaborate on when and when you should not use them, in your opinion? Prehaps give some resources?
@tarunseetha5 жыл бұрын
Sir you are simply awesome. To be honest whenever I stuck for any technical topic, I immediately search on KZbin to check if there is any similar video posted by you. Your way of teaching is too good. Many thanks.
@gokulkrishnanselvaraj23843 жыл бұрын
Sir when we defineing the function we must be call the function that's why the function it's works.but the inner function we don't calling how it's works?
@JasonGabler2 жыл бұрын
Why is this better than a plain, straightforward call to the original function inside a new function without all the abstraction of decorating? This video is great at explaining the mechanics, but even one sentence as to why they are superior would be great.
@samthejam52024 жыл бұрын
Sir I think we should also add an "else" condition so that if we type the larger number first it will also return the answer. def div(a,b): print(a/b) def smart_div(func): def inner(c,d): if c
@asb80352 жыл бұрын
Now I understand WHY I would use a decorator ... simply illustrated and simply understood. We all learn differently and this was concise.
@ZyroZoro5 жыл бұрын
Thank you so much for this video! I've been trying for an hour to wrap my head around decorators (pun intended :P) and this is the first video that's made sense to me.
@hariomjoshi71312 жыл бұрын
Really impressed! Actually I've been through 4-5 videos before, but no one cleared my doubts this easily, that also in just 7 minutes. ❣️ Really loved it.
@mayankjulah44084 жыл бұрын
Can we modify the in-built functions using decorators?
@SreekanthReddy223 жыл бұрын
Sir, I have one doubt. Can't I do like the code mentioned below? def div(a,b): print (a/b) return a/b def inner(a,b, func): if a
@ayushsingh17264 жыл бұрын
Sir please make another video explaining this . Please sir .
@TheKapilsharma1433 жыл бұрын
Hey Navin, Thank you for sharing your amazing knowledge with you, This is the first video in 44 videos which I found a bit harder to grasp.
@feagy2 жыл бұрын
Exactly my thought 🤲
@MohammadIsmailAkheel3 жыл бұрын
how does inner get called and when? what i have understood is we are passing the div function as parameter to the decorator function, which is returning inner_function. Now, the inner_function object or address will be overridden in the ‘div’ because we are capturing the returned function in it. After this, whenever we call div, the execution goes to inner_function in the decorator.
@anishdey35074 жыл бұрын
Hello Sir thank you very much for explaining the topic. I have one question regarding how the value is passed . When the object div1 was created and then in div1(2,4) value was passed , the object div1 was an instance of the function smart_div () which was taking a function as argument only, hence how the object of smart_div which is div1 pass the value 2,4 and got accepted. It will be helpful if you clear my doubt
@kavnainvohra82283 жыл бұрын
I was confused in decorators, but this is the only video from which I really got my confusion cleared! Thanks man, Keep it up
@Pavankumar-xl4ov3 жыл бұрын
Great teaching. But you missed @ syntax. and also can you explain it little deep about why we need to use inner functions etc. I am sure we can't explain decorator concept in just 7mins.
@aishwaryalaxmiveeramalla7394 жыл бұрын
Using the @syntax... def smart_div(div): def inner(x,y): if x < y: x,y = y,x return div(x,y) return inner @smart_div def div(a,b): print(a/b) div(2,4)
@techy-anirban40674 жыл бұрын
Sir could u please make one separate video on decorator elaborately
@bsmaheshkumar53284 жыл бұрын
Why do we have to write the logic inside the function of smart_div()? We could have done that right after smart_div function isn't it? Can anyone, please explain to me about this?
@edwardgregory92194 жыл бұрын
Can you guys help me understand something; If the below code also works (ignoring the ZeroDivision Error) why is there a need to add the additional inner function, as is in the tutorial? def div(a,b): print(a/b) def smartDiv(a,b): if a
@mpakash20412 жыл бұрын
Sir, may I know the reason for returning inner function?
@koushikchhetri88834 жыл бұрын
This could be the possible decorator systex def smart_div(func): def inner(a, b): if(a
@iamdeepika22194 жыл бұрын
Hello sir, I would say your skills always astonish me .Basically I am from ECE background I am facing difficulties to understand these topics So I always used to feel low .but after watching your videos in no time I get motivated and inspired by the way you teach us.you are really doing great work.it means a lot for us.keep doing sir .thank you
@amansinghal3493 жыл бұрын
Hello, I want to pursue ECE because i have interest in electronics field. Can you tell me that which coding language is most important for ECE students and if an ECE student wants a job in software company , then how can they join because they are not tought coding upto that much level which is required for software development.
@dipikapandya31633 жыл бұрын
Same here I am also from ECE background and this is the first language I am learning ... Thank you sir for teaching in such a way that the non it student also easily catch the concepts
@faiyaz76974 жыл бұрын
Hi. If the inner(a,b) function is the one that is responsible to add/modify/influence the code of div(a,b) function, then what is the need to write the inner(a,b) function within smart_div(func) function ?
@nndhore3 жыл бұрын
def div(a,b): return (a/b) print("step1") # step 1:'div' function will be called print(div(1,3)) print("step2") # step 2: 'div' function called and execution complete # (Step 1 & 2 has nothing to do with decorator_function) def decorator_function(func): print("step4") # step 4: 'decorator_function' execution starts. Note that 'inner_function' is still not called def inner_function(a,b): print("step7") # step 7: 'div1' function which is replica of 'inner_function' is being executed if a
@praveerroshan83763 жыл бұрын
@Telusko : I did not understand the use case of this decorator here , can't we just wrap div() in side another function which will just swap the values and pass to div() ? def div(x, y): print(x/y) def smart_div(x,y ): if x
@anilrautela52602 жыл бұрын
Maybe new arguments of div method will also swap. but not sure
@Nnirvana4 жыл бұрын
Before calling the function, what if I swap numbers (let's say prompted from user) checking inside if loop? Correct me if I am wrong.
@saicharan46694 жыл бұрын
Can we do the same thing without using the inner function there ,so that we just make use of smart_ div function directly
@IshitaKapur95 жыл бұрын
def div(a,b): print(a/b) def inner(a,b): if a
@yfjsdgzjdnfn2 жыл бұрын
from math import sqrt def modify(func): def inn(a): return a*a return inn sq=modify(sqrt) print(sq(25)) print(sqrt(25)) My assignment sir 😁😁😁
@shreyashibasaiwal58934 жыл бұрын
Sir,your all videos are awesome indeed.But in this one, i am little bit stuck,i am not getting how smart div func is working,i mean when inner fun has been called and what is the purpose behind returning inner and all.Please,reply asap.SIR
@varungrow60364 жыл бұрын
Really helpful video for me and after a long time I have found a best teacher for guidance in programming .Thank u so much sir
@subomifatoyinbo43223 жыл бұрын
I'll advise you do videos on concepts such as first-class functions and closures; these would help to understand the concept of decorators better. Well done.
@Aavikko125 жыл бұрын
Best decorator tutorial I have found from youtube. Thank you!
@stefkoum8111 Жыл бұрын
You could also do your operation by using a HOF that just receives a function as one of its arguments. No need to return another function. An example: def division(a,b): return a/b def subtraction(a, b): return a - b def do_operation(operation, a, b): return operation(a, b) if a > b else operation(b, a) print(do_operation(division, 4, 12)) # 3.0 print(do_operation(division, 12, 4)) # 3.0 print(do_operation(subtraction, 4, 12)) # 8 print(do_operation(subtraction, 12, 4)) # 8
@sudheerpapasani5415 жыл бұрын
Bro I want to know about generators and Itreators so please have these two in your next video 🙏🙏
@nileshmishra86563 жыл бұрын
Beautifully explained !! I was looking everywhere for a relevant real scenario to test the use of decorators..
@sagarshrivastava46085 жыл бұрын
Sir learnt a lot of Python from your videos... But sir when you were discussing about OOPs concept.. You used the words Abstraction and Encapsulation which you never explained.. A request to you sir. Please make a video on that too..
@ankitgrover76184 жыл бұрын
abstraction stand for abstracting the data or hide the main code of function and show the neseccary detail to user like we are using ac remote,we press the on/off button but we don't know the concept of behind this pressing button this is called abstraction,or encapsulation stands for encapsulate the method/function or variable/variables in the class together is called encapsulation
@rangabharath42535 жыл бұрын
def decorator(func): def new_div(a, b): if a < b: # 2/4 a, b = b, a # 4/2 return func(a, b) return new_div @decorator def div(a, b): print(a/b) div(2, 4) Nice video sir. Awesome as always. I tried using @ symbol above a function. Thank you for the awesome videos. Waiting for the new videos.
@pallasreenivasulu46245 жыл бұрын
sorry broh...i am little confused at @
@rangabharath42535 жыл бұрын
@@pallasreenivasulu4624hi, you have to use @ followed by the decorator function name which you are going to use to add the additional functionality. Then the normal function will get the functionalities of the decorator function. Hope you understand. @ is used to specify that it is a decorator function which is used to extend the functionality of a normal function, without adding the additional code. Thank you.
@pallasreenivasulu46245 жыл бұрын
@@rangabharath4253 Thank you Ranga
@debjyotibanerjee77503 жыл бұрын
This is the best example I found to understand decorator...😀
@learnerlifelong64553 жыл бұрын
I am learning decorator for the first time. I wonder why do we need smart_div function? Can we simply not use inner function, which swaps a and be based on the condition, and finally use div = inner(div) Am I missing something?
@nehasah46932 жыл бұрын
Maybe, in that video, The function, inner(), accept argument a,b Whereas function, smart_div, accept a function 〈(•ˇ‿ˇ•)-→
@taufeequesifat81203 жыл бұрын
2:04 - When a junior dev asks for help from a senior dev
@akashdeep75194 жыл бұрын
what a explanation, great sir, none of other can explain like you. thank you for tutorials.
@vaibhavkrkm4 жыл бұрын
Nice explanation sir :) , by the way, I think we can add '@' also right for using decorators instead of assigning the old function to the new one🤔
@ganeshronge3449 Жыл бұрын
sir i really enjoyed learning python playlist, but sir, i'm totally form mechanical background and in some cases i can't understand the what is happening in the code and why it has been written and i have the dout in the decorators i.e. def div(a,b): print(a/b) def smart_div(func): def inner(a,b): if a
@asishraz61734 жыл бұрын
2:04, Our mom's reaction, when we don't do our housework in this corona time.
@ritikaagarwal73 жыл бұрын
😂
@gopakumars17013 жыл бұрын
could you please create a detailed video on decorators for clarrification?
@g2nd4 жыл бұрын
I like this video but do python developers really lack the creativity to use different variable names? Most of the videos I watch use the same confusing variables like f, f1; tire, tires.
@u03144 жыл бұрын
orrr you could just write this simple lambda expression: smartDiv = lambda a, b : a/b if a > b else b/a
@luckyjoshi67674 жыл бұрын
Lambda can have only 1 expression I suppose dude
@ankitgrover76184 жыл бұрын
sir could you please make a new video on decorators i'm confused in this topic
@savithrisathyanarayanan75684 жыл бұрын
Sir, my name is Krishnan.I am studying eleventh(11) standard . I have doubt whether this course is applicable for me. Kindly reply sir. Great teaching. I have doubt whether my school will teach like you and all the syllabus taught by you. I wanted to use the time judiciously during this corona time
@deltabypi4 жыл бұрын
yes !!!! this is helpful for all 11th and 12th grads to learn in advance
@banderilllero4 жыл бұрын
same thing w/o this stuff: def smart_div(a, b): if a < b: a, b = b, a return div(a, b)
4 жыл бұрын
you are new tesla
@santoshrajput233 жыл бұрын
Those who are looking for the conventional @ syntax way of decorator coding, can use below for the same functionality. def decorator_function(orig_func): def wrapper_function(a,b): if a < b : a,b = b,a return orig_func(a,b) return wrapper_function @decorator_function def div(a,b): print(a/b) div(4,2) div(2,4)
@kanikvijay5244 жыл бұрын
sir can i create decorator without defining the inner function
@saswataacharya54314 жыл бұрын
even after debugging I didn't understand the concept completely.What is inner returning?
@jibinkmathai33704 жыл бұрын
Same doubt...
@himanshudhiman54244 жыл бұрын
Dude we first return inner, which in turn returns func(a,b) where a and b are swapped
@saeedanwar75594 жыл бұрын
@@himanshudhiman5424 can't we swap a and b directly under smart_div and return them, is creating def inner necessary??
@ranadeepreddy70098 ай бұрын
Why can't we write our code directly in smart_div? What is the need of inner function?
@malthaelaoc4 жыл бұрын
Mathematically speaking, decorators make sense. its essentially the concept of two functions, function f, and function g, in which the output of function f is the input of function g, which can be expressed as g(f(x)). The value of f(x) is first computed and then is used as an input for the g function, which further acts on that output, thus "decorating" it. The concept is really simple, one function taking the output of another function as its input. The confusion arises because of Python's mapping, and syntax, which quite honestly, takes a while to "register". So based on the example in this video, for instance, it supposed there is a function called div, which takes two arguments, a and b, and divides a by b, such as: a = int(input("Enter a value for a: ") b = int(input("Enter a value for b: ") def div(a, b): print(a/b) Then the function is called: div(a, b). If the user entered a value to "a", that is less than the value entered to "b", it will result in an output less than 1, and will violate the question. The way this problem can be solved, evidently, is through the use of decorators, which essentially declares a new function, such as div_new that takes the original div function as its input, and makes the necessary adjustments, such as reversing the value of a and b, or computing b/a, so that regardless of if the input value of a < b, the result will yield an integer value greater or equal to 1. Mathematically, the Python code would look like this: [code] def new_div(div(a, b)): def div(a, b): print(a/b) if a < b: print(b/a) new_div(div(a, b)) [/code] Basically, a new function new_div is created that takes the original first function div as its input. Once it goes inside the body of new_div, keeping in mind the values a, and b obtained by the client, it encounters the div function, which performs operations on a, b. Then it exits out of that function and falls into the body of new_div, encountering an if statement that tests the validity of a < b, and if it's True, then it instead prints out b/a, the reverse of a/b, which computes the quotient to a value greater than or equal to 1, without modifying the first function, thus solving the question correctly. This is the logic, though if you try to run that code the way it's written, python will throw all kinds of errors. lol. But for those trying to understand the logic, hope this helps.
@satyammhetre28324 жыл бұрын
Sir can u give some more examples where decorators can be used
@shubhajitchakraborty Жыл бұрын
This guy is a phenomenal teacher.
@PiyushKant-p6i8 ай бұрын
I have been looking for decorators and explanation. It is possible that I might not be looking at the right place or with right keywords but not a single video explained it so u effortlessly as you did. Kudos.
@viswanath5144 жыл бұрын
This is the best and simple explanation of Decorators I ever seen, good job :)
@friendlychannel1004 жыл бұрын
# add functionality to div() without altering div() def smart_div(function): def inner(x, y): if x < y: x, y = y, x if y == 0: print("y cant be zero") return function(x, y) # calling div with new values # return function(x, y) return inner @smart_div # dec def div(a, b): print(a/b) # use '@' or 'div = smart_div(div) ' div(2, 4)
@mikekibet17865 жыл бұрын
Well explained, thank you
@Alphabetbubi5 жыл бұрын
At 6:25 how does the inner function get the parameters of div? How are a and b given into this construct??
@hussainnoor89574 жыл бұрын
so confusing
@meetangad4 жыл бұрын
Sir - Can you advise what is the purpose of return used within smart div and inner?
@Ronitkable2 жыл бұрын
For people saying missing @ in the tutorial, please find the equivalent usage done by the tutor. You could either go with div=smart_div(div) or use @ like @smart_div on top of function div. Both are same
@shashanktripathi30344 жыл бұрын
what is the exact role of the "return inner" statement
@rishitak74194 жыл бұрын
Did you find its answer??
@Dp_writes4 жыл бұрын
Why are we writing function Inside a function? cant we directly Write code only the in smart_div? Thank you for wonderful videos
@sr-ju4lq2 жыл бұрын
Your presence makes the video so much better✨️
@mr.mk7323 Жыл бұрын
So what i got from that is that decarators are functions that help with changing other function without messing with them right?
@luffys_poop Жыл бұрын
You can also decorator like this def smart_div(fun): def inner(a,b): if a
@sameerroshan9542Ай бұрын
why are there two return statements in the decorator? which one is actually utilized?
@zakiasmaa6834Ай бұрын
The best explanation I've seen so far. Thanks a lot Sir
@sreekalapm25884 жыл бұрын
smart alien !.. you taught me this in 7.32 mn where i was trying hard to learn this from other sources for the past few hours
@06_shubhambirhade813 жыл бұрын
Your videos are always helpful, sir can u make some more examples for decorators? so we can get more clear idea of decorators.
@sanjitpaul29533 жыл бұрын
Thank you Sir, now I have understood it properly.
@rajsekharrouthu84384 жыл бұрын
What a fantastic explanation bro
@shillpichaudhary4 жыл бұрын
______________Use of @ in Decorators __________ We simply use @ symbol before the function we would like to decorate. Example : def smart_div(func): def inner_div(a,b): if a
@quant-prep28433 жыл бұрын
telusko could you please use dark mode while teaching? isnt coders prefer dark mode because its strain to the eyes right?
@sachetambere70284 жыл бұрын
hello sir, The changes which we are making in the existing function are permanent or temporary ???
@rakeshvarma18252 жыл бұрын
def smart_div(func): def inner(a,b): if a
@hughp56463 жыл бұрын
Really nice explanation. Well produced video. Thanks!
@mistermanoj31814 жыл бұрын
if put 4,2 instead of 2,4 it doesn't give any output after we have taken in the decorators.Adding else return func(a,b) in definition of inner solves it.
@swamygoskula17853 жыл бұрын
U are a exellent mentor really awesome explanation and very very interesting the way u explained
@rushikeshdhok82494 жыл бұрын
Sir, I have a doubt. why we return the inner I don't understand what it does and why we do that. Please do reply sir. Thank you. I am VSITian
@jibinkmathai33704 жыл бұрын
Same doubt here....
@adarshreddy92293 жыл бұрын
If u don't understand, try watching it again. It just worked for me, Try watchin' it again and again till u get it.
@letstry28544 жыл бұрын
Wao.. excellent explanation sir.... finally my confusion is clear!!
@navaneethjnair69032 жыл бұрын
Sir, Thank U for making decorators so easy. I have watched many videos but did not understood anything. Thanku and a great respect from Kerala 😊😊