Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dyuri/xontrib-pyrtn
Xontrib to store the python return value of commands for the session, mimicking ipython's In/Out.
https://github.com/dyuri/xontrib-pyrtn
python xonsh xontrib
Last synced: 19 days ago
JSON representation
Xontrib to store the python return value of commands for the session, mimicking ipython's In/Out.
- Host: GitHub
- URL: https://github.com/dyuri/xontrib-pyrtn
- Owner: dyuri
- License: mit
- Created: 2021-08-05T19:18:22.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-11T12:27:31.000Z (over 3 years ago)
- Last Synced: 2024-11-09T04:12:16.769Z (about 1 month ago)
- Topics: python, xonsh, xontrib
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-xontribs - pyrtn - IPython like In\[\]/Out\[\] to access python return values in the current session. (Plugins / Prompt tweaks)
README
Store the python return value of commands for the session.
If you like the idea click ⭐ on the repo and tweet.## Installation
To install use pip:
```bash
xpip install xontrib-pyrtn
# or: xpip install -U git+https://github.com/dyuri/xontrib-pyrtn
```## Usage
```bash
xontrib load xontrib_pyrtn
```The xontrib adds two functions to the global namespace - `In[]` and `Out[]`. They are similar to `ipython`'s `In[]` and `Out[]`.
(`In()` and `Out()` is also available and does the same thing, except they can be called w/o argument and will show the list of input/output.)A new `PROMPT_FIELD` `pyhistnum` is also added, to be able to include the number of the upcoming command (like in `ipython`).
## Example
```bash
$ xontrib load pyrtn
$ $PROMPT = "[{pyhistnum}]$ "
[2]$ [12 * 3 + 6]
[42]
[3]$ In[2]
"[12 * 3 + 6]\n"
[4]$ Out[2] + [1]
[42, 1]
[5]$
```## Credits
This package was created with [xontrib cookiecutter template](https://github.com/xonsh/xontrib-cookiecutter).