MCPcopy Index your code
hub / github.com/ipython/ipython / user_expressions

Method user_expressions

IPython/core/interactiveshell.py:2888–2913  ·  view source on GitHub ↗

Evaluate a dict of expressions in the user's namespace. Parameters ---------- expressions : dict A dict with string keys and string values. The expression values should be valid Python expressions, each of which will be evaluated in the u

(self, expressions)

Source from the content-addressed store, hash-verified

2886 return value
2887
2888 def user_expressions(self, expressions):
2889 """Evaluate a dict of expressions in the user's namespace.
2890
2891 Parameters
2892 ----------
2893 expressions : dict
2894 A dict with string keys and string values. The expression values
2895 should be valid Python expressions, each of which will be evaluated
2896 in the user namespace.
2897
2898 Returns
2899 -------
2900 A dict, keyed like the input expressions dict, with the rich mime-typed
2901 display_data of each value.
2902 """
2903 out = {}
2904 user_ns = self.user_ns
2905 global_ns = self.user_global_ns
2906
2907 for key, expr in expressions.items():
2908 try:
2909 value = self._format_user_obj(eval(expr, global_ns, user_ns))
2910 except:
2911 value = self._user_obj_error()
2912 out[key] = value
2913 return out
2914
2915 #-------------------------------------------------------------------------
2916 # Things related to the running of code

Callers 2

test_user_variablesFunction · 0.80
test_user_expressionFunction · 0.80

Calls 2

_format_user_objMethod · 0.95
_user_obj_errorMethod · 0.95

Tested by 2

test_user_variablesFunction · 0.64
test_user_expressionFunction · 0.64