8 ms·
This is great except for the enforcement of double-quotes around all strings and spaces around slice operators. These two choices contradict the standard Pytho
by zestyping 8y ago
This is great except for the enforcement of double-quotes around all strings and spaces around slice operators. These two choices contradict the standard Python documentation, most of the standard library, and the behaviour of the interpreter itself.
When the language itself has an established convention, Black should follow that convention, not fight it. These two weird choices just generate needless churn, which is surprising as it seems Black has quite the opposite goal.
It's a shame, because all the other design choices in Black are pretty good!
- kstrauser 8y agoThat's the #1 complaint I have (and hear) about Black. Everything else, I can live with. And honestly, I can live with using double quotes everywhere, especially when I can type single quotes and then let it re-write them. It's just that they currently look really, really odd to me because that's not how Python is traditionally written.
- stevesimmons 8y agoI prefer a quoting convention of single quotes for text identifiers (as they rarely contain quotes) and double quotes for English text (because contractions are common). Thus: key['first_name'] print("Isn't this clearer?")
- gvx 8y agoI generally follow this convention: 1. Any string literal that contains either ' xor " will be delimited by the other one. 2. For all other string literals, delimit by " if it's meant for human eyes only, delimit by ' if it's meant for computers as well.
- masklinn 8y agoSame, though I'd word the first one as programmatic identifiers. Adopted that from Erlang, where atoms are single-quoted and text strings are double-quoted.
- icebraining 8y agoThe slices thing seems to follow PEP8.
- ambivalence 8y agoColons in slices are implemented to the letter of PEP 8. Your disagreement here probably stems from pycodestyle mistakenly enforcing a different rule (no spaces before colons on if-statements, defs, and so on) in the slice context. The language itself doesn't have an established standard in terms of string quote usage. If it did, Black would follow it. What repr() does is a weak indicator and how the documentation is written is random, there was not only no enforcement as to which quotes to use, there wasn't even a recommendation. Black standardizes on double quotes since it has clear benefits whereas the other option does not.
- komali2 8y agoI'm new to python, I didn't realize there's a difference, can you help me understand the benefits?
- ambivalence 8y agoI put it in the README. Let me know if anything is unclear.
- deleted 8y ago[deleted]
- mixmastamyk 8y agoDouble quotes also have drawbacks, visual noise and the doubling of keypresses required on the most common keyboard layouts.
- ambivalence 8y agoYou can still type single quotes. You have a tool to convert that for you. The visual noise complaint is interesting. Do you also consider the letter W to be more noisy than the letter V? Should we discourage the use of noisy letters in the alphabet?
- mixmastamyk 8y ago
- waleedka 8y agoActually I prefer standardizing on double quotes and I do that in my code on a regular basis. I know some people use a mix, sometimes single quotes and sometimes double quotes, which is fine, but I prefer consistency in this case.
- fishywang 8y agoPEP8 doesn't have a preference between single or double quotes. Black has: > It will replace the latter with the former as long as it does not result in more backslash escapes than before. And I think that's good enough (and in compliance with PEP8)
- jsmeaton 8y agoI have to admit that I was very excited to begin enforcing black on all of our projects at work - until the double quotes decision. I’m used to single quotes everywhere (except docstrings!). I’m probably going to still move to black but I know I’m likely to face some pushback now on this one choice, and I don’t yet have the will to defend it. I also know I’m being mostly unreasonable .. “why is this opinionated tool not perfectly aligned with MY opinions??” .. but feelings.
- nas 8y agoThe double quotes are the only thing that bother me as well. Double quotes are harder to type (on my keyboards) and look more noisy. All other Black formatting I think I could live with. I suppose I can live with double quotes on strings too but I'm not going to like it. ;-)
- deleted 8y ago[deleted]
- cup-of-tea 8y agoComing from a C background I always stuck with double quotes for strings. Single quotes are used for characters in C. I think double quotes are better anyway because an apostrophe is much more likely to turn up in a string than a double quote itself. I rarely have to manually escape quotes inside strings.
- aphextron 8y agoEveryone has an opinion, and this is theirs. That's kind of the whole point.