3 ms·
I wanted to like black but can’t get over the double quote default. I like that they justify it with the less ambiguity and the ability to not have to escape si
by prepend 7y ago
I wanted to like black but can’t get over the double quote default. I like that they justify it with the less ambiguity and the ability to not have to escape single quotes. I even like their proposed fix of just code with singles and reformat into double.
But I don’t like unnecessary different levels of reality (code one way, commit another) and hitting shift quote all those times sucks.
It’s funny how an “opinionated formatter” sounds great in theory until you realize the opinion is “wrong.”
- mixmastamyk 7y agoI've been meaning to make a single quote fork of it, but haven't yet got around to it. Wonder if anyone is interested?
- owl57 7y agoWouldn't a fork of Black with a different formatting choice miss the whole point of Black?
- mixmastamyk 7y agoThe difference is not substantial, just makes it a tad easier to read. Also it depends what you are using it for, 1) to keep your team focused, or 2) enable anyone in the python community to feel comfortable jumping into the project. Given not everyone uses black, #2 is not as common as you'd think.
- prepend 7y agoExcept that it could eventually overtake Black so that Blacker becomes the new norm. I don’t think Black’s dream of all Python looking the same is that worthwhile. Especially if people don’t like some of Black’s decisions. I might use Blacker if it existed, but I’m currently ok with not using Black and just sticking with flake8.
- detaro 7y agoAlthough it at least now has an option to not do anything about quotes, leaving them as they are.
- caymanjim 7y agoI'm not sure when single-quoted strings became the default (at least in Python/Ruby/similar languages), but it's almost entirely about fashion rather than functionality. Double-quoted strings were the norm for literally decades until recently. There is no strong argument for favoring one over the other. So long as everyone uses the same thing (at least within a given project, but ideally within an entire language's work), everything is fine. It's still hard for me to break the double-quote habit because single-quoted strings were unheard of in my entire career until about ten years ago.
- mixmastamyk 7y agoThey both mean the same thing in JS and Python. One is easier to type, easier to read, and used by the Python REPL. Single quotes FTW.
- vonseel 7y agoAnd you've got at least a few single-quotes in your comment through language use of contractions. In code, I prefer whichever style tends to produce the fewest escape-sequence situations. If the code contains hard-coded strings, that's usually double-quotes, though not always. Otherwise I guess it makes less sense to want to push +shift+ everytime you enter a quote on a Python dict key, for example, versus using the single quote.
- paulddraper 7y agoSingle quotes are slightly less noisy. "this", "that", "and", "the", "other" vs 'this', 'that', 'and', 'the', 'other' However, in Ruby, PHP, Groovy, and JavaScript single quotes have actual functional advantages, either through simpler syntax abilities, or by not requiring escaping double quotes for HTML/XML.
- prepend 7y agoI used double quotes for years, but appreciate being able to type more quickly with single quotes. It’s 90% convenience and 10% less clutter since single quotes are just smaller. It’s not a big deal to me as I don’t care too much (similar to tabs vs space). I have a preference but would likely spend zero time caring if my team were trying to decide and would never in a million years try to change someone else’s project.
- mmmrk 7y agoSolution: write in whatever way you want and hit "reformat code" before you git add/commit. Reality reconciled, opinion great again. Addendum for clarification: part of the appeal of autoformatters is that what you type into your editor does not matter. I don't see the "difference of reality" because thanks to black, I don't need to care.
- prepend 7y agoWhat I meant by minimizing different realities is that I would rather avoid situations where I have to write code and look at code differently. I can definitely autoformat on save or on commit, but I’d rather not so I can always “think using the same code” and get used to the same quotes. I’m happy to adopt to other folks projects as I don’t want to convert anyone. But purposely working on my own projects with a quote different than the record seems like an extra effort, even if minimal.