News for hackers. Stuff that matters.
Re:Django: Reformatted code with Black by supreme_berry on Tuesday February 08, 2022 @10:13AM (#30259294)
“Black” developer refused for a long time to add option to format code with single quotes with very aggressive manners. Now Django devs didn’t see that option for single quotes and code looks unpleasant.
Re:Django: Reformatted code with Black by vitorfs on Tuesday February 08, 2022 @10:25AM (#30259469)
I have always used single quotes for Python code since I start working with it. When I started to adopt Black on my projects it indeed felt weird and the code looked unpleasant. But after a while you get used to it.

Some people make the case that it's easier to write single quotes (well, depending on the keyboard format anyway). For keyboards in the US standard you have to hold the Shift key to write a double quote. But the good thing about Black is that you can still write your code using single quote and when you run the command line utility it will fix/normalize the code to use double quotes.

Nowadays I got so used to it that I even write my Python code using double quotes. And looking at Python code using single quotes looks weird/unpleasant for me.

Re:Django: Reformatted code with Black by spc476 on Tuesday February 08, 2022 @08:29PM (#30267457)
I use single quotes for items that, while technically a string, could be considered a value or symbol. For example:

     syslog('debug',"Just opened %s for output",filename)
While there's no semantic difference between single and double quote, in my code base, there is. And if black becomes very popular, why even support single quotes anymore?
Re:Django: Reformatted code with Black by digisign on Tuesday February 08, 2022 @01:30PM (#30262394)
The repl still uses single quotes.
Re:Django: Reformatted code with Black by INTPenis on Tuesday February 08, 2022 @11:04AM (#30260059)
I reacted to this too, in the changed files tab.

Technically single or double quotes have the exact same meaning in Python. What makes people use single quotes is probably other languages like PHP, Perl and Bash.

I know I've made it a habit to default to single quotes unless I know I need double quotes. So that might be where the habit comes from in the Django project. But it's not actually necessary in python so might as well use the most commonly used type of quote.

Re:Django: Reformatted code with Black by pchf on Tuesday February 08, 2022 @03:48PM (#30264464)
To keep the single quotes, which in my opinion make the code less cluttered and closer to the REPL, I use the pre-commit hook double-quote-string-fixer, in conjunction with black's option skip-string-normalization set to true.
Re:Django: Reformatted code with Black by dplgk on Thursday February 10, 2022 @10:49AM (#30287854)
And black is supposed to make our lives easier?
Re:Django: Reformatted code with Black by digisign on Tuesday February 08, 2022 @01:31PM (#30262407)
Use nero or blue instead, which both use single quotes.