def extrapolate_statistics(scope):
 c = {}
 for (k, v) in list(scope.items()):
  if isinstance(v, dict):
   v = extrapolate_statistics(v)
  elif isinstance(v, (list, tuple)):
   v = [extrapolate_statistics(record) for record in v]
  elif hasattr(v, '__call__'):
   v = v(scope)
  c[k] = v
 return c

def extrapolate_statistics ( scope ) : c = { } for ( k , v ) in list ( scope . items ( ) ) : if isinstance ( v , dict ) : v = extrapolate_statistics ( v ) elif isinstance ( v , ( list , tuple ) ) : v = [ extrapolate_statistics ( record ) for record in v ] elif hasattr ( v , '__call__' ) : v = v ( scope ) c [ k ] = v return c
return an extrapolated copy of the given scope .