Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/coldfix/pyval
Print python objects values from command line
https://github.com/coldfix/pyval
Last synced: 25 days ago
JSON representation
Print python objects values from command line
- Host: GitHub
- URL: https://github.com/coldfix/pyval
- Owner: coldfix
- Created: 2019-06-10T16:32:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T21:59:52.000Z (over 3 years ago)
- Last Synced: 2023-11-20T16:05:00.826Z (12 months ago)
- Language: Python
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- Changelog: CHANGES.rst
Awesome Lists containing this project
README
pyval
=====Show the value of a python object via command line.
Examples:
.. code-block:: bash
$ pyval sys.platform
linuxThis is meant to provide a more convenient alternative to:
.. code-block:: bash
python -c "import sys; print(sys.platform)"
More complex expressions are possible too:
.. code-block:: bash
$ pyval math.pi**2
9.869604401089358$ pyval 'math.sin(math.pi/4)'
0.7071067811865475The output can be influenced using one of the following command line
arguments:=========================== ================================================
``-r, --repr`` Print ``repr(obj)``
``-j, --json`` Print ``json.dumps(obj)``
``-p, --pprint`` Print ``pprint(obj)``
``-f SPEC, --format SPEC`` Print ``format(obj, SPEC)``
=========================== ================================================Installation
------------The utility can be installed as follows::
pip install --user eval
It is also possible to simply download ``val.py`` and symlink or move under
the name of your choice into your PATH, e.g.:.. code-block:: bash
wget https://raw.githubusercontent.com/coldfix/pyval/master/val.py \
-O ~/.local/bin/pyvalOnce either of these is done, it can be used within any python enviroment on
your system, as long as it is accessible in PATH.By default it uses the currently activated environment. In order to use it
with unactivated python interpreter, you currently have to call the
interpreter manually as follows::/path/to/python ~/.local/bin/pyval 'math.sin(math.sin/3)'
This module is kept deliberately simple and avoids any dependencies not in the
standard library. This allows running the script in any python environment
once it is installed on the system, without having to install it in each
environment individually.