-: There is a unique thing that we can do with functions
that we haven't seen before,
and they're called docstrings.
Let me show you what I mean.
If I had a function here,
and we'll just call it test,
and test, let's say receives a parameter that is a.
And, in here, it's going to print a.
What a useless, completely useless function.
Now, if I run this,
well, nothing's going to happen
because I have to call test and then say,
well, exclamation marks.
And, you see that our function works.
But, we can actually with functions in Python,
use something called docstrings,
and it looks something like this.
You do single quote, single quote, single quote,
so three of them,
and then, at the bottom, once again,
single quote, single quote, single quote.
So, at the beginning of the function, like this,
and, in here, I can add some info about the function.
For example, "this function tests and prints peram a."
Now, here's the interesting part.
If I run test here,
and I do brackets,
look at that.
My editor tells me,
"Info: this function tests and prints peram a."
This is called a docstring.
And, what it allows us to do
is to actually comment inside of our functions
in a way that if another person,
let's say is using the test function,
they can actually, let's say, in the future,
when we write large applications
where it's not just 10 lines of code
or maybe we have different files.
Instead of just finding what test does,
as I'm typing it,
it's going to tell me,
"Hey, test is going to return or print peram a."
So, I find out information about this,
and if we ever use something like length, for example,
and run this,
you see that this gives us information
about the function by using docstrings,
but it comes built in with Python.
Another way to view this,
minds you, when we talk about developer environments,
our editors are going to do this automatically.
But, there's a few other ways
that we can actually read this.
For example, I can do the help function,
which we haven't seen before,
which comes pre-built with Python,
and we don't wanna call the function.
I just wanna call help on test.
If I run this,
look at that.
I get test(a).
Info: this function tests and prints param a.
So, we can use help to find out what a function does,
which is really, really useful.
One other way to do this
is to use what we call a magic method,
or a dunder method, which, again,
we'll get into later on in the course.
I do double underscore,
then I do doc,
and then double underscore, like this.
If I click run,
well, we have to print something here.
So, let's print, click run,
and look at that, I get the same thing.
So, these docstrings are really, really useful
to add comments and definitions to your functions,
so that when other people on your let's say team
or coworkers come across your function that you created,
they're able to understand what it does right away
without searching through your Python files
or multiple files.
Very useful feature.