Extended Comments for Python 3?

  • Context: Python 
  • Thread starter Thread starter WWGD
  • Start date Start date
  • Tags Tags
    Python
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
10 replies · 2K views
Messages
7,828
Reaction score
13,157
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.
 
Physics news on Phys.org
It should be two keys to the right of the L by using the Shift key.
 
  • Like
Likes   Reactions: 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?
 
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   Reactions: 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.
 
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   Reactions: WWGD
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.
 
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: