Skip to main content

A calculator REPL CLI with mpmath and ECB exchange rates

Project description

calculator-cli

calculator-cli opens the standard Python REPL 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-1.0.1.tar.gz (10.9 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-1.0.1-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: calculator_cli-1.0.1.tar.gz
  • Upload date:
  • Size: 10.9 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-1.0.1.tar.gz
Algorithm Hash digest
SHA256 3efc74ea26be488d85c8f20fb807e5473d8bbdca452eae97cb3850f0ecee44e9
MD5 4a4d05c7bd61893c24a10a7f9cd9db0a
BLAKE2b-256 ba934a8faef4d7d0e2c32379a29f1d881c99216ec352f40fa9e7128e10d24c85

See more details on using hashes here.

File details

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

File metadata

  • Download URL: calculator_cli-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 11.2 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-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a210cf40d6ceccbdee932a8d80cbcd138a67da2528bdf706c29bfdb3acbae7b3
MD5 0504bd7b8ae05a9c6e08570bb2996e86
BLAKE2b-256 0d35383a43df7235c524dee38fd5d85f4f02bfdd1cae9402e2bcef02cee4024c

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