#NEWLINE# def computed_values( d ) : #NEWLINE# #INDENT# '\n    Computes a new `dict` that has callable values replaced with the return values.\n\n    Simple example:\n\n        >>> compute_values({"foo": lambda: "bar"})\n        {"foo": "bar"}\n\n    Arbitrarily deep structures are supported. The logic is as follows:\n\n    1. If the value is callable, call it and make that the new value.\n    2. If the value is an instance of dict, use ComputableDict to compute its keys.\n\n    Example:\n\n        >>> def parents():\n        ...     return {\n        ...         "father": lambda: "Foo",\n        ...         "mother": "Bar"\n        ...      }\n        ...\n        >>> a = {\n        ...     "name": "Brad",\n        ...     "parents": parents\n        ... }\n        ...\n        >>> computed_values(a)\n        {"name": "Brad", "parents": {"father": "Foo", "mother": "Bar"}}\n\n    :rtype: dict\n    ' #NEWLINE# result = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for ( k , v ) in six . iteritems ( d ) : #NEWLINE# #INDENT# if callable ( v ) : #NEWLINE# #INDENT# v = v ( ) #NEWLINE# #UNINDENT# if isinstance ( v , dict ) : #NEWLINE# #INDENT# v = computed_values ( v ) #NEWLINE# #UNINDENT# result [ k ] = v #NEWLINE# #UNINDENT# return result