Skip to main content

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:

  • calculator
  • c

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 c before 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

calculator_cli-2.0.1.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

calculator_cli-2.0.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file calculator_cli-2.0.1.tar.gz.

File metadata

  • Download URL: calculator_cli-2.0.1.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

Hashes for calculator_cli-2.0.1.tar.gz
Algorithm Hash digest
SHA256 5eab9f76aabc37e14c41d66448ca0ee1189a921bf1ae5bbd81aba06320b8a0d2
MD5 7174f3f5c7ef20d2ceba92669d6036db
BLAKE2b-256 0e6d4b1cc7fc1da2d82099d5c5383613cbb8e6fd3318961a6025086ed2588d19

See more details on using hashes here.

File details

Details for the file calculator_cli-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: calculator_cli-2.0.1-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

Hashes for calculator_cli-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 77ddf302e85f447ebefb18556a8ca5ebc3a2b3b26fc26d5f18bee3055735cd8d
MD5 3687e7c3461d0e966793c6df7aadfb85
BLAKE2b-256 32a86b17347813122e4a69d73c94a0086d3280f71e4571841cb31df108c61941

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page