Which type of quotation marks are the best or the right ones to use, the single or the double ones? I tend to use double quotation marks because I find those easier to find and use on my Scandinavian keyboard (they do not share the same key) but I would love to hear what you guys suggest.
For example in Python:
print("Hello world!")
print('Hello world!')
Quotation marks, single or double? Which ones do you use and why?
Top comments (10)
Single- and double quotes behave differently depending on the language you're using. For example, in PHP, variables are interpreted inside double-quotes:
So single-quotes are I suppose infinitesimally faster. Don't worry about that.
For general text, use double-quotes, because you're way more likely to use a single-quote as a substitute for an apostrophe in blocks of text than you are to include a quotation.
Single and double quotes mean totally different things in languages like C and C++.
The OP's question is ill-formed.
Just use the default settings of Prettier and stop overthinking things.
For example at bash command line prompt:
you will get significantly different output as the kind of quotation really matters.
In other words: Use the quotation marks appropriate for the specific use case and refrain from the idea that there are "best or the right ones to use".
In Python I often prefer to use in for example f-strings the triple quotation marks as they allow me to use any single other ones in the string's text. SciTE as text editor has Python highlighting supporting different styles for all the different Python quotation mark variants you can then use to "colorize" your coding:
Happy coding in New Year 2024 to you!
P.S. in the oOo way of approaching programming any usual ASCII Unicode characters will be considered to be a comment if not used within special marked blocks. so there will be no special meaning for quotation marks and no reason to prefer one over the other. And I you want the quotes to be less disruptive use single quotation marks.
Single quotes (in English) are typically used for a quote within a quote. For example: I told my friend, "According to California State University San Marcos (my online source), 'Single Quotation Marks are used to indicate dialogue within another quotation.'"
Double quotes are perfectly fine, I do use them from time to time on my own blog posts. Any quotes of interest can be technically represented using double quotes. However, with the Markdown format, one should use ">" symbol as shown below.
As long as an English Teacher is not having a look at your code, it's fine. Jk, You can use any of them if you are using programming languages like Python, JS, etc. What I did when I shifted from Java, I used single quotations for characters and double quotations for strings 'coz of my habit. And, now I use the one that does not let me overthink.
I perfer single
Single
Some comments have been hidden by the post's author - find out more