004 - Pure, Functional, Financial Python Katas

Easy one today.

Take a look at downloading data from Google using Pandas Data Reader.

import pandas_datareader.data as web  
import datetime  
start = datetime.datetime(2010, 1, 1)  
end = datetime.datetime(2013, 1, 27)  
f = web.DataReader("F", 'google', start, end)  

Again convert to lambdas.

I get something like this for start.

start = lambda: datetime.datetime(2010, 1, 1)  

As an aside, usually if I wrap an object in a lambda it becomes immutable (i.e. safe and easier to understand) i.e. if I try to change the month or the day it stays the same because the lambda is fixed.

But datetime objects are themselves immutable, so adding lambdas doesn't actually give us much extra.

One thing I learned today, is that container objects - lists, dictionaries and sets - are usually mutable, whereas value objects - floats, strings, datetimes and tuples(!) are immutable.

Good to know.