Python Extended Comments for Python 3?

  • Thread starter Thread starter WWGD
  • Start date Start date
  • Tags Tags
    Python
AI Thread Summary
The discussion centers around the challenges of creating extended comments in Python using triple quotes. The original poster struggles to locate the necessary keys on their Qwerty keyboard to type these quotes. They receive guidance that the straight double quotes can be used instead of the left and right quotation marks, which are automatically converted in some programs like Word. It is clarified that in Python, simple straight quotes (ASCII 34) should suffice for comments. Additionally, the use of triple quotes for multiline comments is described as a workaround rather than an official syntax. The conversation includes references to a table of Unicode characters and a demonstration of how to implement comments in Python code, highlighting that the approach discussed was initially misunderstood.
WWGD
Science Advisor
Homework Helper
Messages
7,707
Reaction score
12,823
Hi All,
I am having trouble figuring out how to do extended, i.e., many-lined, comments. I know the format is ( copied from website):

“”””
Problem is that, while I can find the '' in my Qwerty keyboard, I can't figure out how to find the rest in my keyboard. I assume all Qwertys are the same but if including a pic file of my keyboard helps, please let me know.
TIA.
 
Technology news on Phys.org
It should be two keys to the right of the L by using the Shift key.
 
  • Like
Likes WWGD
Borg said:
It should be two keys to the right of the L by using the Shift key.
Thanks, that gives me the " , but not the ones leaning to the other side.
EDIT2: Would a macro that copied the needed image work?
 
It seems num lock key does it:

"'''
 
WWGD said:
It seems num lock key does it:
"'''
They are just straight quotes when you type them. In some programs like Word, they automatically convert to the left and right versions.
 
  • Like
Likes WWGD
Borg said:
They are just straight quotes when you type them. In some programs like Word, they automatically convert to the left and right versions.
It does happen in Word, you're right. But copying and pasting did not work, unfortunately.
 
  • Like
Likes WWGD
WWGD said:
It does happen in Word, you're right. But copying and pasting did not work, unfortunately.
If you're copying from Word (or a web page), they've already been changed into something else. You should be able to just put straight quotes in python and have it work.
 
  • Like
Likes WWGD
  • #10
DrClaude said:
To be clear: you do not want open and close quotes, just simple "straight" double quotes, ASCII 34.
Also true in C, C++, and many other programming languages.
 
  • #11
DrClaude said:
To be clear: you do not want open and close quotes, just simple "straight" double quotes, ASCII 34.

Note also that the use of triple quotes for comments appears to be a trick, not an actual block comment syntax in python: https://stackoverflow.com/questions/7696924/way-to-create-multiline-comments-in-python
'''
Thanks
'''
EDIT: As a demonstration, and to make up for my Noobishness:
def Myfunction():
print('hello')

'''
Nonsense
'''

Myfunction()

Output in IDLE:
RESTART: C:/Users/.../AppData/Local/Programs/Python/Python37-32/Comment.py
hello
My apologies, I was trying what I read online by using just comments, without any code.
 
Last edited:

Similar threads

Replies
10
Views
3K
Replies
4
Views
1K
Replies
12
Views
8K
Replies
10
Views
2K
Replies
4
Views
5K
Replies
15
Views
2K
Back
Top