There is a unique thing that we can do with functions that we haven't seen before, and they're called
dark strings.
Let me show you what I mean.
If I had a function here and we'll just call it a test and test, let's say receives a parameter that
is a and in here it's going to print a lot of 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 dark strings.
And it looks something like this.
You do a single code, single code, single code.
So three of them.
And then at the bottom, once again, single code.
Single code, single code.
So the beginning of the function like this.
And in here I can add some info about the function.
For example, this function tests and prince.
Perram, A.
Now, here's the interesting part, if I run tests here and I do brackets, look at that.
My editor tells me info this function tests and prints param a this is called a dark string.
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 ten 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 Perama.
So I find out information about this.
And if we ever use something like LENTH, for example, and run this, you see that this gives us information
about the function by using dark strings, but it comes built in with PyCon.
Another way to view this, mind 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 want to call the function, I just want to call help on test if I run this.
Look at that, I get test info, this function tests and prints Perama 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 Dundar 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 dark strings are really, really useful to add comments and definitions to your functions so
that when other people on your, let's say, team or co-workers 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.