From f55fcf43bdf27a25cd2ba715a8d06527413c6e0e Mon Sep 17 00:00:00 2001 From: Kodi Arfer Date: Mon, 3 Jul 2017 17:00:55 -0700 Subject: [PATCH] Add a docstring for hy-eval It's just a copy of the documentation for hy.core.langauge.eval. --- hy/importer.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hy/importer.py b/hy/importer.py index 6f40d3d..ce58190 100644 --- a/hy/importer.py +++ b/hy/importer.py @@ -144,6 +144,19 @@ def import_buffer_to_module(module_name, buf): def hy_eval(hytree, namespace=None, module_name=None, ast_callback=None): + """``eval`` evaluates a quoted expression and returns the value. The optional + second and third arguments specify the dictionary of globals to use and the + module name. The globals dictionary defaults to ``(local)`` and the module + name defaults to the name of the current module. + + => (eval '(print "Hello World")) + "Hello World" + + If you want to evaluate a string, use ``read-str`` to convert it to a + form first: + + => (eval (read-str "(+ 1 1)")) + 2""" if namespace is None: frame = inspect.stack()[1][0] namespace = inspect.getargvalues(frame).locals