def function_key_generator(namespace, fn, to_str=compat.string_type):
 if (namespace is None):
  namespace = ('%s:%s' % (fn.__module__, fn.__name__))
 else:
  namespace = ('%s:%s|%s' % (fn.__module__, fn.__name__, namespace))
 args = inspect.getargspec(fn)
 has_self = (args[0] and (args[0][0] in ('self', 'cls')))
 def generate_key(*args, **kw):
  if kw:
   raise ValueError("dogpile.cache's default key creation function does not accept keyword arguments.")
  if has_self:
   args = args[1:]
  return ((namespace + '|') + ' '.join(map(to_str, args)))
 return generate_key

def function_key_generator ( namespace , fn , to_str = compat . string_type ) : if ( namespace is None ) : namespace = ( '%s:%s' % ( fn . __module__ , fn . __name__ ) ) else : namespace = ( '%s:%s|%s' % ( fn . __module__ , fn . __name__ , namespace ) ) args = inspect . getargspec ( fn ) has_self = ( args [ 0 ] and ( args [ 0 ] [ 0 ] in ( 'self' , 'cls' ) ) ) def generate_key ( * args , ** kw ) : if kw : raise ValueError ( "dogpile.cache's default key creation function does not accept keyword arguments." ) if has_self : args = args [ 1 : ] return ( ( namespace + '|' ) + ' ' . join ( map ( to_str , args ) ) ) return generate_key
return a function that generates a string key .