added exec functions
diff --git a/docs/advanced.rst b/docs/advanced.rst
index c257fa2..a13bc2b 100644
--- a/docs/advanced.rst
+++ b/docs/advanced.rst
@@ -1611,3 +1611,33 @@
.. [#f4] http://www.sphinx-doc.org
.. [#f5] http://github.com/pybind/python_example
+
+Calling Python from C++
+=======================
+
+Pybind11 also allows to call python code from C++. Note that this code assumes, that the intepreter is already initialized.
+
+.. code-block:: cpp
+
+ // get the main module, so we can access and declare stuff
+ py::module main_module = py::module::import("__main__");
+
+ //get the main namespace, so I can declare variables
+ py::object main_namespace = main_module.attr("__dict__");
+
+ //now execute code
+ py::exec(
+ "print('Hello World1!')\n"
+ "print('Other Data');",
+ main_namespace);
+
+ //execute a single statement
+ py::exec_statement("x=42", main_namespace);
+
+ //ok, now I want to get the result of a statement, we'll use x in this example
+ py::object res = py::eval("x");
+ std:cout << "Yielded: " << res.cast<int>() << std::endl;
+
+ //or we can execute a file within the same content
+ py::exec_file("my_script.py", main_namespace);
+
diff --git a/docs/reference.rst b/docs/reference.rst
index 4df4344..e3fe018 100644
--- a/docs/reference.rst
+++ b/docs/reference.rst
@@ -244,3 +244,26 @@
.. function:: name::name(const char *value)
Used to specify the function name
+
+Calling Python from C++
+=======================
+
+.. function:: eval(str string, object global = object(), object local = object())
+
+ Evaluate a statement, i.e. one that does not yield None.
+ The return value the result of the expression. It throws pybind11::error_already_set if the commands are invalid.
+
+.. function:: exec(str string, object global = object(), object local = object())
+
+ Execute a set of statements. The return value the result of the code. It throws pybind11::error_already_set if the commands are invalid.
+
+.. function:: exec_statement(str string, object global = object(), object local = object())
+
+ Execute a single statement. The return value the result of the code. It throws pybind11::error_already_set if the commands are invalid.
+
+.. function:: exec_file(str filename, object global = object(), object local = object())
+
+ Execute a file. The function exec_file will throw std::invalid_argument if the file cannot be opened.
+ The return value the result of the code. It throws pybind11::error_already_set if the commands are invalid and
+ std::invalid_argument if the file cannot be opened.
+