least-astonishment

Recurring dates on dates that do not exist

When giving the option for something to reoccur every certain amount of time how should I treat times that don't reoccur on every interval? For example what should happen to birthday reminders for February 29th? Or if I have a monthly appointment on the 31st what should happen on months that do not have a 31st day? What do you believe ...

"Least Astonishment" in Python: The Mutable Default Argument

Anyone tinkering with python long enough has been bit (or torn to pieces) by the following issue: def foo(a=[]): a.append(5) return a Python novices would expect this function to always return a list with only one element: [5]. The result is instead very different, and very astonishing (for a novice): >>> foo() [5] >>> foo() ...

"Boolean" operations in Python (ie: the and/or operators)

This method searches for the first group of word characters (ie: [a-zA-Z0-9_]), returning the first matched group or None in case of failure. def test(str): m = re.search(r'(\w+)', str) if m: return m.group(1) return None The same function can be rewritten as: def test2(str): m = re.search(r'(\w+)', str) r...