DEV Community


Discussion on: Python beyond PEP8

rhymes profile image

Surrender to the robots :-)

Prettier for JS defaults to double quotes
Rubocop for Ruby defaults to double quotes
black for Python defaults to double quotes and gives a good reason for it:

The main reason to standardize on a single form of quotes is aesthetics. Having one kind of quotes everywhere reduces reader distraction. It will also enable a future version of Black to merge consecutive string literals that ended up on the same line (see #26 for details).

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.

Thread Thread
claytron profile image
Clayton Parker

Rubocop defaults to single quotes because double quotes do more escaping and interpolation.

Thread Thread
rhymes profile image

Thanks Clayton, I remembered it wrongly!

Forem Open with the Forem app