Proposal for changing string literal syntax to only support double quotes Body

hi

I am a Python user and I would like to open a discussion regarding the way Python handles string delimiters.

Currently, Python supports both single quotes (') and double quotes (") to define strings. From a user experience perspective, this can lead to confusion—specifically when a user wants to include an apostrophe (like in the word “don’t”) inside a string wrapped in single quotes. This causes a syntax error because the parser interprets the internal apostrophe as the end of the string.

I am proposing a change to the language where only double quotes (") are used to define strings, and single quotes are treated as standard characters rather than delimiters.

I understand that this is a major change to the language syntax, but I am interested in hearing from the core developers about:

  1. Why this dual-delimiter system was originally chosen over a single-delimiter system.

  2. What the specific technical barriers would be if a future version of Python were to deprecate single-quote delimiters.

  3. How such a change would impact existing codebases.

I look forward to your thoughts and technical insights on this design choice

Very VERY negatively. This change would break every program that ever uses single quote string literals.

Instead of changing the language, I suggest creating a rule in your editor, linter, or code formatter, to enforce this on your own codebase. There are a LOT of excellent tools out there (some highly opinionated, others more flexible) that can help you to catch bugs.

Why would you want to change this? If you want to embed a single quote in your string, you can use double quotes for the delimiters. If you want to embed a double quote in your string, use single quotes for the delimiters.

From my user perspective, when I started Python over twenty years ago, this was actually very convenient and not confusing at all.

Oh, and nowadays you can even use triple quotes (“”") if you want to embed both single and double quotes. Is that also confusing?

This is a serious breaking change since all code that uses single quotes would no longer work. As such, it were considered at all, it would have to be considered only for Python 4, and I don’t think Python 4 is ever happening. (Even then, this change would almost definitely not be considered for the reasons mentioned in other replies.)

No. Post must be at least 10 characters.

OK. Hell No!

I find it’s more common for me to be trying to use double-quotes inside strings (because I’m often writing code that generates C strings) so I have the opposite problem to you.

Can we ban double-quote strings too?

I can’t speak to what Guido was thinking when the decision was originally made, but some potential factors:

  • as others have mentioned, double quotes are handy when you have embedded apostrophes or single quotes, while single quotes are handy when you have embedded double quotes. Triple quoting and explicit backslash escapes are only needed for this purpose when you need to embed a mix of both
  • for folks coming from C (which was more common when it was still rare for people to learn Python as their first program language), the dual syntax allowed them to retain the practice of writing single character literals with single quotes and longer strings with double quotes (characters and strings are different types in C, but a single type in Python)

For style consistency, I believe automatic formatters generally have standardised on “use double quotes, unless the string literal contains double quotes”.