What is docstrings? To quote PEP 257 from python's own documentation, " A docstring is a string literal that occurs as the first statement in a module, function, class, or method definition. Such a docstring becomes the __doc__ special attribute of that object. " To ease this definition out, basically, a docstring is a piece of string or a small note which is generally provided in a class, function or a method definition for informing as well as documenting important information about the class, function or the method. There are two basic types of docstrings, which are oneliner docstrings and multiline docstrings. How to write docstrings? docstrings are generally literal strings and therefore you can write them within """ triple double quotes""". But there are certain rules in case of unicode or backslashes. If your docstring information is supposed to have backslash character then you have to use r"""raw triple double quot...
I write about machine learning models, python programming, web scraping, statistical tests and other coding or data science related things I find interesting. Read, learn and grow with me!