🎓 Welcome back to Digital Academy, the Complete Python Development Tutorial for Beginners, which will help you Learn Python from A to Z!
🖥️ Documenting your Code in Python: Docstring in Python
Although optional, documentation is a good programming practice - especially if you want to get your dreamed job at Google, Apple, Facebook or anywhere in the World! Plus, unless you can remember what you had for dinner last week, always documenting your code will help you a lot when you will need to stay away for a while, then come back.
You can attach documentation in Python to a function definition by including a string literal called docstring, just after the function header. It is briefly used to explain what a function does.
○ What is a Docstring in Python?
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.
Note: Docstrings in Python are usually triple quoted, to allow for multi-line descriptions.
○ Documenting your Code in Python: Docstrings in Python
def hello():
"""This function prints
message on the screen"""
print('Hello, World!')
○ Print Function Help (Rich format)
To print a function’s documentation, use the Python help() function and pass the function’s name as parameter.
help(hello)
Help on function hello in module __main__:
hello()
This function prints
message on the screen
○ Print Function Help (RAW format)
You can also access the docstring in Python through _doc_ attribute of the function.
print(hello.__doc__)
OUTPUT: This function prints message on the screen
Let's play this video, stick around and watch until the end of this video! 👍🏻
- Digital Academy™ 🎓
***
☞ WATCH NEXT:
○ Data Types in Python - • DATA TYPES in Python (Numbers, String...
○ Operators in Python - • OPERATORS in Python (Arithmetic, Assi...
○ IF Statements in Python - • CONDITIONAL Statements in Python (IF,...
○ FOR Loops in Python - • FOR Loop in Python (Syntax, Break, Co...
📖 Blog: http://digital.academy.free.fr/blog
📖 [FULL Course] HOW TO Learn Python? Python Tutorial for Beginners: • 🐍 Python 101: Learn Python Basics for...
📖 [PLAYLIST] Complete Python Development Course for Beginners: http://digital.academy.free.fr/playli...
🧑🎓 [COURSE] http://digital.academy.free.fr/courses
📘 [BOOK] Python for Absolute Beginners: https://amzn.to/3NvyOWV
🛒 Shopping and Discounts: http://digital.academy.free.fr/store
💌 Weekly Newsletter for Developers: https://www.getrevue.co/profile/digit...
#Python #Tutorial #Beginners #Shorts
***
♡ Thanks for watching and supporting ♡
Please Subscribe. Hit the notification bell.
Like, Comment and Share.
***
♡ FOLLOW US ♡
✧ http://digital.academy.free.fr/
✧ / digitalacademyy
✧ / digitalacademyfr
✧ / digital_academy_fr
✧ / digitalacademyonline
♡ SUPPORT US ♡
✧ http://digital.academy.free.fr/join
✧ http://digital.academy.free.fr/store
✧ http://digital.academy.free.fr/donate
✧ http://digital.academy.free.fr/subscribe
✧ / digital_academy
✧ https://www.buymeacoffee.com/digital_...
***
Смотрите видео Documenting a Function in Python: DOCSTRING in Python - Python Tutorial for Beginners онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Digital Academy 21 Апрель 2021, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 1,002 раз и оно понравилось 22 людям.