Python Extended Comments for Python 3?

  • Thread starter WWGD
  • Start date

WWGD

Science Advisor
Gold Member
4,137
1,724
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.
 

Borg

Science Advisor
Gold Member
1,809
2,012
It should be two keys to the right of the L by using the Shift key.
 

WWGD

Science Advisor
Gold Member
4,137
1,724
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?
 

WWGD

Science Advisor
Gold Member
4,137
1,724
It seems num lock key does it:

"'''
 

Borg

Science Advisor
Gold Member
1,809
2,012
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.
 

WWGD

Science Advisor
Gold Member
4,137
1,724
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.
 

Borg

Science Advisor
Gold Member
1,809
2,012
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.
 
32,344
4,130
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.
 

WWGD

Science Advisor
Gold Member
4,137
1,724
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:

Want to reply to this thread?

"Extended Comments for Python 3?" You must log in or register to reply here.

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving
Top