-: Hi guys, and welcome back.
In this video, we're going to learn
about decorating functions with parameters.
So, let's take a look at our example,
and do a little bit more with it.
Here we've got our make secure decorator
and our get admin password function.
If instead of get admin password
we wanted to change this to get password
and take in a panel decorator and then do something like
if panel is admin then return one, two, three, four
otherwise if panel is billing
then return super secure password.
Something like that.
Now, of course, when you call the function
you're going to have to pass an A panel, such as billing.
But this function actually won't take in the argument
because our function here, calls the original function
without the argument.
So here's what's gonna happen when you call get password.
Remember, get password is replaced by secure function.
So, secure function at the moment
does not have any parameters
so you won't be able to pass billing to it.
In addition, when you call the original function
no argument is passed either,
so even if this function took the argument in,
it wouldn't be passed in then.
So obviously we have to fix that.
We have to put the panel in there and the panel in there.
Then what happens is billing gets passed to secure function
then it gets passed to the original function
which is get password, and then this will work.
However, this is not good
because we have coupled our make secure decorator
to this function.
That means that we can't use it on other functions
that take in different arguments.
So instead, what you usually do with decorators,
is you make them take unlimited numbers
of arguments and keyword arguments
so you can cater for everything.
Then once you do that, as you may know already,
is star args and star, star kwargs.
And then you just pass them on as well
to the original function.
So that will make it work and also it won't limit you
to using it with only this function.
You can use it with any other function.
This get password here must still be called
with the correct argument for the original function.
But this one here doesn't care
what arguments are passed in.
That's everything for this video.
Thank you for joining me in this one,
and I'll see you in the next one.