Python Tutorial for Beginners-Part-04- commenting python
Python Tutorial for Beginners-Part-04- commenting python
Python Tutorial for Beginners
Part-04 -Commenting in Python
What are comments ?
Valuable information or discription about code written
- Comments enhance code readability.
- Purpose comments help humans to understand code better and in easier.
- Ignored by compilers and interpreters.
- Helps in code mentaiblity
Commenting in python
--------------------
Single line comment
-------------------
For single line commenting # (pound) sign is used
# this is a single line comment and it will not get executed
# this is another line, which is commented
Usually you see this line in Python files.
------------------------------------------
#!/user/bin/env python
points Python interpreter path on Unix like systems.
Multiple line comment.
--------------------
In Python multi-line or block commenting is done by using # (pound) sign on each line.
# This is the first line
# This is second line
# This is third line
# Comments continue
There is misconception about, people use triple quotes for commenting.
Actually triple quotes are used to represent multi-line string.
Double quotes, multi-line string.
-------------------------------
"""
this is first line
this is second line
this is third line
this is fourth line
this is fifth line
like this many lines can be added
"""
Single quote multi-line string.
-------------------------------
'''
This is an example to show
how multi line string is added
to python file.
'''
- Using triple quotes for commenting is a bad practice, avoid it.
- Comments are to briefly explain about code functionality.
Not to block a piece of code form execution.
docstring
-----------
Multi line string block is also used to add to docstring to Python file.
docstring is short hand for documentation strings.
Just Learn Python
All about Python programming,
In this channel you will find videos related various Python programming topics,
Like tutorials, Exercises, code snippets, Projects, tips and tricks of Python,
Python best practices , Python tutorials, Real life examples, coding practices, interview questions.
Видео Python Tutorial for Beginners-Part-04- commenting python автора Python: новая эпоха разработки
Видео Python Tutorial for Beginners-Part-04- commenting python автора Python: новая эпоха разработки
Информация
3 декабря 2023 г. 19:16:34
00:04:09
Похожие видео