diff options
| author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-03-24 13:39:54 -0400 |
|---|---|---|
| committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2021-03-24 16:33:27 -0400 |
| commit | fc3c9b9e17e3cb89f771cc618517ebd968730938 (patch) | |
| tree | fabbd6858c6090c78e80a037b3fbfdfd13f02123 /docs/features | |
| parent | ae03c59de609878e068920380667c5fd45f26650 (diff) | |
| download | cmd2-git-fc3c9b9e17e3cb89f771cc618517ebd968730938.tar.gz | |
Removed ipy's access to the CLI's globals() dictionary
Diffstat (limited to 'docs/features')
| -rw-r--r-- | docs/features/embedded_python_shells.rst | 13 |
1 files changed, 4 insertions, 9 deletions
diff --git a/docs/features/embedded_python_shells.rst b/docs/features/embedded_python_shells.rst index 71fb8197..cbedf992 100644 --- a/docs/features/embedded_python_shells.rst +++ b/docs/features/embedded_python_shells.rst @@ -12,6 +12,9 @@ You may optionally enable full access to to your application by setting python session, which is a reference to your ``cmd2`` application. This can be useful for debugging your application. +Any local or global variable created within the Python session will not persist +in the CLI's environment. + Anything in ``self.py_locals`` is always available in the Python environment. The ``app`` object (or your custom name) provides access to application @@ -48,14 +51,6 @@ More Python examples: >>> quit() Python was here > -Using the ``py`` command is tightly integrated with your main ``cmd2`` -application and any variables created or changed will persist for the life of -the application:: - - (Cmd) py x = 5 - (Cmd) py print(x) - 5 - The ``py`` command also allows you to run Python scripts via ``py run('myscript.py')``. This provides a more complicated and more powerful scripting capability than that provided by the simple text file scripts @@ -113,7 +108,7 @@ The ``ipy`` command enters an interactive IPython_ session. Similar to an interactive Python session, this shell can access your application instance via ``self`` if ``self.self_in_py`` is ``True`` and any changes to your application made via ``self`` will persist. However, any local or global variable created -within the ``ipy`` shell will not persist. +within the ``ipy`` shell will not persist in the CLI's environment Also, as in the interactive Python session, the ``ipy`` shell has access to the contents of ``self.py_locals`` and can call back into the application using the |
