DEV Community

Discussion on: Enforcing single quotes in Python

Collapse
 
rhymes profile image
rhymes

I use black and I'm fine with the double quotes. From their documentation:

Why settle on double quotes? They anticipate apostrophes in English text. They match the docstring standard described in PEP 257. An empty string in double quotes ("") is impossible to confuse with a one double-quote regardless of fonts and syntax highlighting used. On top of this, double quotes for strings are consistent with C which Python interacts a lot with.

On certain keyboard layouts like US English, typing single quotes is a bit easier than double quotes. The latter requires use of the Shift key. My recommendation here is to keep using whatever is faster to type and let Black handle the transformation.

from github.com/psf/black/blob/master/d...

they explain there's a way not to enforce quotes normalization using --skip-string-normalization but I've never tried it.

You can also use it with flake8 if you want to go further in syntax checking: black.readthedocs.io/en/stable/com...

My recommendation is to surrender to the double quotes :D