Space Mission Design is a complex process, filled with challenges and triumphs, and it all starts with a simple idea. Every great space mission begins with a purpose. This could range from the…
Docstring is a short form for “documentation string”.
Docstrings are nothing but a type of multi-line comments which we use in Python. They are used to describe a function, method, class or module that you use in your code.
When you are adding a docstring into your code, that particular description has to be written in between triple quotes as follows.
So isn’t it just another comment? ❓
No! There is something special about docstrings.
The position! If you are adding a docstring to your code, you MUST type it right after the definition of that particular function, method, class or module. And that’s how docstrings be different from other comments.
Let me show you an example.
Still…Isn’t it another comment? 😧
Nope! Here comes the surprise!
You can access docstrings using a very simple line of code. How?
The syntax we use to access a docstring is as follows.
Let’s try to access the docstring of our above example.
Output:
Try by yourself and enjoy guys because as long as you enjoy what you learn, they will amaze you more and make you comfortable with it.
This is the end of this article and I hope you learnt something new. Good luck guys!
Are you wondering what the differences are between freeze dried foods and dehydrated foods? There are of differences. First of all, the processes used to preserve the food and stop spoilage and…
While some businesses regard customer support as the way their representatives talk to the customers, the overall scope is actually larger than just that one conversation. Customer support is a…
Summer season is below and some homeowners is fixing or swapping out their roof covering ahead of the the winter season climatic conditions hits. No matter whether you will have a fashionable roof…