The difference between git pull and git fetch

git pull is git fetch followed by a merge. That one sentence is the whole answer, and it is easier to trust once you have watched what each half does to your repository.

var functionName = function() {} vs function functionName() {}

The difference is when the function exists. Everything else — the name, the error message, what happens in a block — follows from that.

Why a mutable default argument in Python is shared between calls

A function with def f(x, into=[]) does not get a fresh list on each call. It gets the same one, every time, for the lifetime of the program. Here is why, and what to do instead.

Does Python have a ternary conditional operator?

Yes, and the syntax reads differently from every other language that has one. This article shows how it works, and why the two older idioms you still find in the wild are not equivalent to it.

How slicing works in Python

Slicing is one of the things that makes Python pleasant, and one of the things people half-learn and then guess at. This article covers the grammar, the two behaviours that surprise people, and what a slice copy actually copies.

How to access the index in a Python for loop

Python’s for loop hands you the elements, not their positions. When you need the position as well there is a built-in for it, and a C-style workaround that most people write first.

How to check if a list is empty in Python

There is one idiomatic way to do this, it is also the fastest, and it catches rather more than an empty list — which is fine until the day it is not.

How to create a directory and its missing parents in Python

Creating a directory is one call. Creating one several levels deep, without failing when it already exists and without a race condition, needs two keyword arguments that are easy to forget.

How to find the index of an item in a Python list

list.index() answers the question in one call. What it does when the item is not there, when the item appears twice, and what it costs on a large list are the parts worth knowing.

How to flatten a list of lists in Python

Turning [[1, 2], [3, 4]] into [1, 2, 3, 4] has one obvious answer, one tempting answer that gets slow, and one recursive answer that crashes on strings if you write it the natural way.