It seems scipy once provided a function mad to calculate the mean absolute deviation for a set of numbers:
mad
http://projects.scipy.org/scipy/browser/trunk
If you enjoy working in Pandas (like I do), it has a useful function for the mean absolute deviation:
import pandas as pd df = pd.DataFrame() df['a'] = [1, 1, 2, 2, 4, 6, 9] df['a'].mad()
Output: 2.3673469387755106