Re:Black: An uncompromising Python code formatter
by woolvalley on Friday May 25, 2018 @04:12PM
(#17157472)
Eh, many programming languages use double quotes for strings, and single quotes for singular characters. Languages that can use single quotes for strings that I know of are ruby and python.
[ Parent
| on HN ]
Re:Black: An uncompromising Python code formatter
by ComputerGuru on Friday May 25, 2018 @04:34PM
(#17157691)
Don’t forget VimL, the language that insanely decided to use double quotes as a “start of comment” indicator, then went back and gave them special meaning based on their position so they either signal the start of a comment or a string.
Re:Black: An uncompromising Python code formatter
by prawl on Friday May 25, 2018 @10:34PM
(#17159844)
A different comment character could have been chosen, but this affects nothing. It's not insane.
Re:Black: An uncompromising Python code formatter
by samatman on Friday May 25, 2018 @04:21PM
(#17157554)
Lua, and there are others. I favor double quotes for this same reason even when single quotes are allowed.
I'd like «guillemets» but that's going to have to be self-serve...
Re:Black: An uncompromising Python code formatter
by spc476 on Saturday May 26, 2018 @03:34AM
(#17160691)
I use single quotes when the string in question is used like an enumeration:
set_color('black','white')
And double quotes for strings meant to be read by a human: print("Hello there. How are you?")
And an example with both forms: syslog('warning',"unit %s spin rate %f too low",u,rate)
For me, it's an indication of how I expect the string to be used.
Re:Black: An uncompromising Python code formatter
by Inityx on Friday May 25, 2018 @04:25PM
(#17157597)
And even then, Perl and Ruby (heck, even Bash) have a semantic difference between double- and single-quoted strings. The only other popular general-purpose languages where they're synonymous are PHP, JavaScript, and Lua.
Re:Black: An uncompromising Python code formatter
by ComputerGuru on Friday May 25, 2018 @04:31PM
(#17157670)
>The only other popular general-purpose languages where they're synonymous are PHP, JavaScript, and Lua.
PHP does treat single and double quotes differently. Contents of single quotes strings are not parsed for variable substitution.