A calculator REPL CLI with mpmath and ECB exchange rates
Project description
calculator-cli
calculator-cli opens an embedded Python console with mpmath loaded into the namespace and ECB exchange conversion built in. The package is available on PyPI at calculator-cli.
Downloads
Latest release is on GitHub Releases. Standalone binaries are available for Windows, macOS, and Linux:
Each archive contains both commands:
calculatorc
After downloading, you can extract the archive and either run the binaries directly or move them to a directory in your PATH.
[!IMPORTANT] Standalone binaries are built with PyInstaller and published to the latest GitHub release. On macOS and Linux, extract the archive and run
chmod +x calculator cbefore the first launch if needed.
Examples:
calculator.exe --help
c.exe
chmod +x calculator c
./calculator --help
./c
It's also possible to install the package with pip
pip install calculator-cli
Run
You can run the REPL with
calculator
Help message
calculator --help
REPL Usage
Normal Python expressions stay normal Python expressions:
1 / 3
2 ** 10
The _ variable is stored as the last result and can be used as in the usual Python REPL.
mpmath names are already loaded, so mpmath expressions work directly:
sin(pi)
sqrt(2)
quad(lambda x: exp(-x**2), [0, inf])
sin(pi) is displayed as 0 because the REPL display hook uses mpmath.chop(...) before printing.
Exchange helpers are also available:
convert(100, "EUR", "USD")
refresh_exchange()
convert(...) returns an mpmath.mpf, so _ stays numeric and can be reused in later calculations. In the REPL it is displayed as:
116.84 USD [on 2026-04-13]
Exchange cache
On every startup the app runs refresh_exchange().
- The cache file is
ecb_rates.json. - The file stores the ECB rate date, the local retrieval date, and the currency table.
- If the cache was already retrieved today, no network request is made.
- If today is different, the app fetches the ECB XML feed again and rewrites the cache.
Default cache location:
- Windows:
%LOCALAPPDATA%\calculator-cli\ecb_rates.json - Unix-like systems:
${XDG_CACHE_HOME:-~/.cache}/calculator-cli/ecb_rates.json
You can also specify a custom cache location with the --cache option
calculator --cache ./cache
Local Install
git clone https://github.com/alex180500/calculator-cli.git
cd calculator-cli
uv sync
Then you can run the REPL with uv run calculator or uv run c.
License
This package is distributed under Apache-2.0 License. This means that you can use the code freely for academic, personal, or commercial purposes! If you use my code extensively, I would greatly appreciate if you could credit me by linking my GitHub profile @alex180500 or just reference me (Alessandro Romancino) in any way.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file calculator_cli-2.0.2.tar.gz.
File metadata
- Download URL: calculator_cli-2.0.2.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68e0013f1e68e34a9f084da8dc693b5846d10bd7c6910200fc176195b426d6e3
|
|
| MD5 |
90a29c821356868d9c3b485dd8558d40
|
|
| BLAKE2b-256 |
33064f3079166062f711eac501aed37d806fb4db39414783f6b41e9d47abe2fd
|
File details
Details for the file calculator_cli-2.0.2-py3-none-any.whl.
File metadata
- Download URL: calculator_cli-2.0.2-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cfe4704f04437ca4d5cef23e31075d9ce2da45cb37fab90f690ab5523895914c
|
|
| MD5 |
58561499dccc610ab424783b5871e119
|
|
| BLAKE2b-256 |
e3828701c3f729a4360e1e9eb22fb231fc89bff507da92302f291244aaeb7201
|