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.

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]

Run

uv run calculator
uv run c

Help:

uv run calculator --help

Custom cache directory:

uv run calculator --cache ./cache

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

Local Install

uv sync

uv run calculator

License

This package is distributed under the Apache-2.0 License.

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.0.tar.gz (11.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.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: calculator_cli-2.0.0.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.0.tar.gz
Algorithm Hash digest
SHA256 2f01d6c4a2fb321d0dd5f733fffa999158ee3702f80c0e66d719038436559786
MD5 198f46a815bd9ef9dc1aa958167c059c
BLAKE2b-256 09546937d860466cef130ef6173798c1e6e1253f65f5ba58d8f140c7901d7bdf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: calculator_cli-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.6 {"installer":{"name":"uv","version":"0.11.6","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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 050f6d1fcf9577533268a7ff072c829421afd39ff3a1c34e481b0f024a86f98e
MD5 39d6b1b9273684cd59ae4281d3e3092c
BLAKE2b-256 1fc114e859b1d4fcfc9263b21bd273ab76db2f0af30dc40764c1f5053d1a9400

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