What is a Docstring in Python | EP-46 Docstring in Python | How to Use Docstrings in Python | Python

Subscribers:
28,000
Published on ● Video Link: https://www.youtube.com/watch?v=Sf1fMvX6KLY



Duration: 0:00
57 views
2


Python documentation strings (or docstrings).Docstrings are a type of comment used in Python to document.They provide a concise explanation of what the code does, its parameters, return values,and any potential side effects.A docstring is placed immediately after the definition of a function. It's enclosed in triple single quotes”’ or “”” triple double quotes.All functions should have a docstring."""

1. Triple-Quoted Strings
"""This is the most common docstring format in Python. It involves using triple quotes (either single or double) to enclose the documentation text. Triple-quoted strings can span multiple lines and are often placed immediately below the function"""

def my_function():
'''Demonstrates triple double quotes
docstrings and does nothing really.'''

print("Using __doc__:",my_function.__doc__)


2. Google Style Docstrings
"""Google style docstrings follow a specific format and are inspired by Google’s documentation style guide. They provide a structured way to document Python code, including parameters, return values, and descriptions."""
def multiply_numbers(a, b):
"""
Multiplies two numbers and returns the result.

Args:
a (int): The first number.
b (int): The second number.

Returns:
int: The product of a and b.
"""
return a * b
print(multiply_numbers(3,5))

3.Numpydoc Style Docstrings
"""Numpydoc-style docstrings are widely used in the scientific and data analysis community, particularly for documenting functions and classes related to numerical computations and data manipulation. It is an extension of Google-style docstrings, with some additional conventions for documenting parameters and return values."""
def divide_numbers(a, b):
"""
Divide two numbers.

Parameters
----------
a : float
The dividend.
b : float
The divisor.

Returns
-------
float
The quotient of the division.
Raises
------
TypeError: If b is a zero

"""
if b == 0:
raise ValueError("Division by zero is not allowed.")
return a / b
print(divide_numbers(3,2))

#PythonDocstrings #PythonForBeginners #PythonTutorial #LearnPython #PythonProgramming #CodeWithPython #PythonTips #PythonCourse #ProgrammingTips #PythonDocumentation #Python #Docstrings #Programming #SoftwareDevelopment #CodeQuality #PythonTutorial #CodingTips #Developer #TechTips

Connect With Us:
—————————————
➡ ️ Websitehttps://www.cybrosys.com/m/
➡ ️ Email: info@cybrosys.com
➡ ️ Twihttps://twitter.com/cybrosysosys  
➡ ️ Lihttps://www.linkedin.com/company/cybrosys/brosys  
➡ ️ https://www.facebook.com/cybrosystechnologiesnologies  
➡ ️ https://www.instagram.com/cybrosystech/brosystech  
https://pinterest.com/cybrosys/  / cybrosys  




Other Videos By Cybrosys Technologies


2024-10-09What is Nested Function in Python | EP-48 Nested Function | Function within Function | Python Videos
2024-10-09How to Import Images in Odoo 18 | Import Product Images in Odoo 18 | Odoo 18 New Features | Odoo 18
2024-10-09How to Manage Empty Location in Odoo 18 Inventory | How to Filter Zero Stock in Odoo 18 | Odoo 18
2024-10-08What is One Line & Multi Line Docstring in Python | EP-47 Docstring in Python Part 2 | Python Videos
2024-10-08How to Export Employee Data From Horilla HRMS | Free HRMS Software | Free Employee Management System
2024-10-08How to Translate Odoo 18 Website in Any Language with AI | Translation with AI in Odoo 18 Website
2024-10-07What is Bidirectional Replication (BDR) in Odoo | R&D Sneak Peek | BDR
2024-10-07Revamp in Odoo 18 Document | Odoo 18 New Features | Odoo 18 Release Date | Odoo 18 Document App
2024-10-07How to Configure Multiple Approvals for Leave Requests in Horilla HRMS | Free HR Software| Best HRMS
2024-10-07How to Publish Job Position on Third-Party Job Board in Odoo 18 Recruitment | Odoo 18 New Features
2024-10-06What is a Docstring in Python | EP-46 Docstring in Python | How to Use Docstrings in Python | Python
2024-10-04Revamp in Odoo 18 Debug | Odoo 18 New Features | Odoo 18 Release Date | Odoo 18 Debug Mode
2024-10-04What is Bi-Directional Replication (BDR) in Odoo | How BDR Can Revolutionize Your Odoo Deployments
2024-10-03How to Install Odoo 18 with Pycharm | Setup Odoo 18 Development Environment Using Pycharm in Ubuntu
2024-10-03How to Unblock Payment in Odoo 18 Accounting | Odoo 18 Accounting Tutorials | Odoo 18 New Features
2024-10-03Trend Lines in Odoo Chart in Odoo 18 | Odoo 18 New Features | Odoo 18 Release Date | Odoo 18 Chart
2024-10-02How to Add New Employee in Horilla HRMS | Create New Employee in HRMS Software | Free HR Software
2024-10-01What is Keyworded Variable Length Arguments | EP-45 Arbitrary Keyword Arguments | Python Tutorials
2024-10-01How to Import Employee Data to Horilla HRMS | Free HRMS Software | Free Employee Management Software
2024-10-01What are the Types of Charts in Odoo 18 Spreadsheet | Odoo 18 Chart Type in Spreadsheet | Odoo 18
2024-09-30How to Manage Rotating Work Shifts in a Company Using Horilla HRMS | Implement Rotating Work Shifts