Skip to playerSkip to main contentSkip to footer
  • 5/21/2025
Docstrings, short for documentation strings, serve as explanations for code segments in Python. They are multiline strings enclosed in triple quotes ("""Docstring goes here""" or '''Docstring goes here''') placed immediately after the definition of a function, class, method, or module. Unlike regular comments, docstrings are accessible at runtime and are used to generate documentation.
Docstrings are used to explain what a function, class, method, or module does, not how it does it. They should be concise and informative, providing enough detail for users to understand the purpose and usage of the code element.

Category

📚
Learning
Transcript
00:00The quality of the code is directly related to readability and cleanliness.
00:11How clean code is written and how new code is used for it is easy to use code.
00:18The first step is documentation.
00:24The first step is to define the code when the next user uses the function.
00:32For example, this function has written a print function.
00:38Basically, Python and volunteers have written a lot of programmers.
00:44Let's see what this function is.
00:46What if I want to know more about this function?
00:49How can I know about this function?
00:50I can call the help function.
00:54I can simply say that I will help.
00:56I will execute it.
00:58And then, look, this is all the help.
01:01This function is a print function.
01:03This parameter is a value, separator, end line.
01:06This file can also be used for flush.
01:09This options are the options.
01:11Then, the details of the print function is a value.
01:14Then, it will be operation.
01:16It will be file, separator, end.
01:18option is what we can do.
01:19We can insert string between value and defined space.
01:22Cool.
01:23So this means that if I look at this print function, if I look at this complete usage, then
01:31I can understand it.
01:32It's like I have a function called, and all the things I have made in my face.
01:36So, you can see that you have a function of the content to the function.
01:43We can see that it is descriptive.
01:45So you can see it.
01:46So we can select the function of the function.
01:49Then we can select the function of the function.
01:52And you can see nothing.
01:55Basically, you should be able to see that you don't see anything.
02:01You can see that you can see a string here.
02:06And that's it.
02:09So you can see that the function of the function is called.
02:12So, the print function has helped add, how can we add?
02:18We can use Doc String to use Doc String to add.
02:21Doc String to define three double quotes or single quotes.
02:25For example, I put single quotes three times,
02:29or double quotes three times, just like this,
02:32and closing three times double quotes, just like this.
02:35Now, what you can write is the Doc String to help.
02:41For example, I say,
02:43function creates,
02:49and then I say,
02:54and then I say,
02:56name takes name, amount takes amount, amount is returned so that it can be used further.
03:17Further.
03:18Okay.
03:19So, what do you do?
03:20What do you do?
03:21That is the description.
03:22The amount is returned,
03:23and you can use it further.
03:24If you call the help function on the receipt,
03:28then you can see what happens.
03:30Wow!
03:31Now, your function is more descriptive.
03:32Basically,
03:33the code is not needed to see the user.
03:37It's simple.
03:38It's simple.
03:39You can say,
03:40this is the receipt.
03:41I can see,
03:42this is the receipt function.
03:43I can tell you,
03:44it's built-in.
03:45This is how to use it.
03:46How to use it?
03:47Help function is called here.
03:48Okay.
03:49Name and amount.
03:50Receipt function create receipt.
03:52Okay.
03:53Good.
03:54Name.
03:55Name.
03:56Amount.
03:57Amount.
03:58Amount.
03:59Amount.
04:00Amount.
04:01Amount is a string.
04:02Okay.
04:03Amount is a string.
04:05Okay.
04:06So,
04:07idea is better.
04:08Okay.
04:09I will execute it.
04:10Now,
04:11directly,
04:12help show us.
04:13You can use a new user.
04:15Okay.
04:16It's a very,
04:17very big help.
04:18That,
04:19that it is easy to know.
04:20That,
04:21okay.
04:22This function,
04:23value,
04:24return to the value.
04:25This is an entire user.
04:26So the code application has been added.
04:27You can add the code.
04:28As far as if,
04:29the code is possible,
04:30you can add the code.
04:31The code is also important.
04:32But,
04:33you know,
04:34you can add the code.
04:35It's better for the code.
04:36You can add the code,
04:37now,
04:38you can add the code.
04:39This is a inicioul.
04:41This is a recipt.
04:43This is a recipt.
04:45This is a recipt.
04:47This is a recipt.
04:49Just like that.
04:51I can copy, control-C, control-V can go on.
04:53And this is a recipt.
04:55They are not the same thing.
04:57They are not the same thing.
04:59They are not the same thing.
05:01Help function in this composition
05:03This has just a static string.
05:05Okay?
05:06You can use it anywhere.
05:07You can use it.
05:08You can use the help method and retrieve it.
05:11This is just for readability.
05:13For example, I will remove it.
05:16And I will simplify it.
05:18This function creates zipped.
05:20I will say this is done using commenting.
05:26Okay?
05:27If I call help function,
05:29basically, help function is totally ignored.
05:32Hashtag is not dot string.
05:35Dot string is when you want to document your code.
05:38You want to give a description.
05:40So, you can use the help function.
05:44Excellent.
05:45You can also see the help method.
05:50Basically, dinder method.
05:52You can double underscore.
05:54Dock double underscore.
05:56You will get exactly the same result.
06:00Okay?
06:01So, this is basically dinder method.
06:04Basically, we will print it here.
06:07To see the result.
06:08So, I will print it.
06:10Wrap up.
06:11This dinder method is called object oriented programming.
06:13We will learn to do two method methods.
06:15You can use the help function function.
06:17You can use the help function function.
06:19You can use the help function function.
06:21So, again, you will show the help.
06:23Okay?
06:24So, let's close this to you.
06:25Here is a small step to you.
06:26That I will share the extension method.
06:27This is the return method.
06:31It is not.
06:32Right?
06:33I am sorry.
06:34I am sorry.
06:35That is the return method.
06:36You can just write it.
06:38After this option.
06:39I don't give up.
06:41You can write it.
06:42So, I am going to put it this way.
06:43This is the return method method.
06:45But, you can write.
06:46Like, this is the return method.
06:47그러면,
06:48You can write it.
06:49return encounter ہوتا ہے
06:50loop, joh block of code
06:53ہے, وہ break ہو جاتا ہے
06:54तो line 59
06:57execute ही نہیں ہوگی
06:59तो आपने यह चीज़ अपने जहन में रखनी है
07:00कि return, first time
07:02used हुआ, excellent, second time
07:05not accepted, ठीक है
07:06यहाँ पर 59, जो है, वो execute ही
07:08نہیں होगी, तो आपने यह चीज़ अपने जहन में
07:10रखनी है, कि return, first time
07:12जब use हुआ, excellent, second time
07:15not accepted, ठीक है, यहाँ पर code break हो जाएगा
07:18और यहाँ पर exit कर जाएगा
07:20code, ठीक है, इस line पर
07:22इसके नीचे जाएगा ही नहीं, ठीक है
07:23तो आपने यह चीज़ अपने जहन में रखनी है

Recommended