as commented by danielgtaylor, use len() instead of value.__len()__
see http://stackoverflow.com/questions/2481421/difference-between-len-and-len