def get_context_from_function_and_args(function, args, kwargs):
 for arg in itertools.chain(kwargs.values(), args):
  if isinstance(arg, RequestContext):
   return arg
 return None

def get_context_from_function_and_args ( function , args , kwargs ) : for arg in itertools . chain ( kwargs . values ( ) , args ) : if isinstance ( arg , RequestContext ) : return arg return None
find an arg of type requestcontext and return it .