recentpopularlog in

kme : codingstyle   25

coding style - Single quotes vs. double quotes in Python - Stack Overflow
I like to use double quotes around strings that are used for interpolation or that are natural language messages, and single quotes for small symbol-like strings, but will break the rules if the strings contain quotes, or if I forget. I use triple double quotes for docstrings and raw string literals for regular expressions even if they aren't needed.
python  quotes  quotingstyle  codingstyle  bestpractices 
11 weeks ago by kme
psf/black: The uncompromising Python code formatter
Black is a well-behaved Unix-style command-line tool:

* it does nothing if no sources are passed to it;
* it will read from standard input and write to standard output if - is used as the filename;
* it only outputs messages to users on standard error; exits with code 0 unless an internal error occurred (or --check was used).
python  codingstyle  codestyle  formatter 
11 weeks ago by kme
uncrustify/uncrustify: Code beautifier
Source Code Beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA
devel  cplusplus  linter  codingstyle  alternativeto  artisticstyle 
december 2017 by kme
autopep8 1.3.3 : Python Package Index
<code class="language-bash">
$ autopep8 --in-place --aggressive --aggressive --max-line-length 78 <filename>
</code>
pep8  linter  devel  codingstyle  solution 
december 2017 by kme
JavaScript syntax - Wikipedia
Initial semicolons are also sometimes used at the start of JavaScript libraries, in case they are appended to another library that omits a trailing semicolon, as this can result in ambiguity of the initial statement.
javascript  semicolons  styleguide  codingstyle  webdevel  explained  solution 
january 2017 by kme
JavaScript Semicolon Insertion
\
The spec goes on to suggest, "In the circumstance that an assignment statement must begin with a left parenthesis, it is a good idea for the programmer to provide an explicit semicolon at the end of the preceding statement rather than to rely on automatic semicolon insertion." A more robust alternative where semicolons are intentionally omitted is to include the semicolon at the beginning of the line, directly before the token that introduces the potential ambiguity:

a = b + c
;(d + e).print()

Statements beginning with open parentheses or square braces are somewhat rare, but do arise in practice. </blockquote
javascript  semicolons  codingstyle  styleguide  webdevel  solution 
january 2017 by kme
Do you recommend using semicolons after every statement in JavaScript? - Stack Overflow


An ambiguous case that breaks in the absence of a semicolon:

// define a function
var fn = function () {
//...
} // semicolon missing at this line

// then execute some code inside a closure
(function () {
//...
})();

This will be interpreted as:

var fn = function () {
//...
}(function () {
//...
})();

We end up passing the second function as an argument to the first function and then trying to call the result of the first function call as a function. The second function will fail with a "... is not a function" error at runtime.
javascript  styleguide  codingstyle  semicolons  isnotafunction 
january 2017 by kme

Copy this bookmark:





to read