Skip to main content

A calculator CLI application based on Python and mpmath

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: calculator_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 9.8 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.0.tar.gz
Algorithm Hash digest
SHA256 8a5754198b555c0f1c7ab85daee9251bf51c163b554559858fc851d38c54d11f
MD5 9425a244232162ade2f96360687f31b9
BLAKE2b-256 80bea04b796ace651cef213225e758b0cd870f2267666a992522fdb684af8870

See more details on using hashes here.

File details

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

File metadata

  • Download URL: calculator_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 11.0 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dde6fd0d9ef271800de5fdb421799260227c4827da7ec13307a7978e6d309e23
MD5 e6e34561f043c5cf2c9e7b539cd40cc2
BLAKE2b-256 6d96f513146fcc259e04ed515effe422954d82152cbef6cbe64f2c8377261b28

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