We are going to discuss Biton closer's, so indecision at first we shall define what is a python.
Clouzot then you should explain it with one demonstration for the understanding.
So here is the definition of python.
Closer it close.
It is a function object that remembers the values in including scopes, even if they are not present
in the memory, I think to have the better clarity.
Let us explain it with one practical demonstration to implement disclosers in Python.
Before getting that detailed idea, what is the closer we must be having a crystal clear idea regarding
that, what is that nested function and what is nonlocal variable?
So we should have the understanding that what is that nested function and what is a nonlocal variable
before going for discloser functions.
It function will be defined.
If it is defined inside out of the function, then obviously that function will be called as a nested
function.
Nested functions can access variables of the enclosing scope, will be discussing all these things,
using this example.
So now here to see this is our one method is there and within this method we have to find out of the
method.
So this is this method will be called as the nested method.
Nested function and business to function can access the variables, which is within the scope that is
within the inclosing scope in Python.
This nonlocal variables are read-only by default, and we must declare them explicitly as nonlocal and
to in order to modify them for in order to object with some new halloo.
So let us go for one example here.
So here you have defined one method.
That is a message.
We stick this message as input parameter and we have defined one nested method.
That is the print message inor intentionally.
I've given this name of this method as print message inor and which print this message.
You see this message is defined in this inclosing scope.
So that's why this message can be accessed from this inner method.
So now return print message innot.
So this inner function has been returned here.
So now how to access it.
So here to see we are calling this method that is the outer method, that is the print message and passing
the screen.
There is a hello, this string we are passing which will be assigned to this message and now it is its
output will be will be taken into available.
Let it be another.
So this another is actually containing the reference of this inner method.
That is a print message inor.
So from there, if you call that is another method then this hello is getting printed and there is a
feature of discloser has got implemented in this example.
So let us go for another example for the better understanding.
So here to see here, you have to find one method.
There is a multiplier outr having this N as the input parameter and that is one nested method.
Is there nested function, is there there is a multiplier underscored in it.
So this by method requires one input argument that is about X and this outer variable that is a nonlocal
variable that is out in can be accessed from this multiplied inner function.
So return Eckstut n and it returns this nested method as output.
So now we are calling this outer a multipolar outer function with this parameter three, this parameter
three will be assigned to this in here.
So it is it has been assigned two times three.
It has been the same two times five when the five has been has been passed as the input parameter.
So now you see the inner method.
There is a multiplier equals one parameter for its execution.
So here we are calling this one as times three nine.
So here you can find that N has got initialized with three and this X has got initialized with this
nine.
So whenever I'm just executing this one, it should print 27.
So now let me execute the code here so you can see that it is printing 27.
It it is printing 27 because it is actually multiplying three and nine.
So in this particular call, you can find that this five is getting assigned to this end so that now
there is at times five, so times five, three.
So these three will be assigned to X, so three into five.
So that's why it will return the respective 15 trying to five to return the respective 15.
So now consider this one.
So now here you see times three.
So N has got the value three.
And here we are passing this to here.
So then what is the value here.
So two into three.
Six so six will be the input arguing for these times.
Five.
So five has got assigned to this end already because times five we pass this fight over this multiple
output method.
So that's why the five has got assigned to an already.
And here you are having the six and the six will be assigned to this X and then X into N, so that means
six into five.
So will be the required outcome.
So in this way, in this particular example, we have defined that how this KLOSER functions can be
used in our python coding.
Thanks for watching this video.