Skip to main content

What is simplecalc?

A simple calculator, able to parse quite complex expressions:

>>> from simplecalc import calc
>>> calc("2 + 3.5")
'5.5'
>>> calc("2 * log(100)")
'4'
>>> calc("sin(pi / 2)")
'1'
>>> calc("3 * 5!")
'360'
>>> calc("3 * 5! + ceil(sqrt(123) / ln(10))")
'368'
>>> calc("3**e  * 5! + ceil(sqrt(123) * ln(10))")
'2394.55888943'

Note that these expressions are NOT evaluated by eval() or anything like that, so it should be safe to get the expressions from untrusted sources. Use at your own risk, of course.

It can also be used as a script:

$ simplecalc "3 * cos(pi)"
-3

Project’s history

Code here comes from other internal Canonical’s project, this part was opensourced in 2018:

https://launchpad.net/simple-calc

I forked that to bring it to GitHub, migrate it to Python 3, shape it more like a project (have a setup.py, etc.), and do some releases.

Metadata

Release files for pysimplecalc 1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysimplecalc 1
File Size Uploaded
pysimplecalc-1.tar.gz 8.7 kB Details

Release files / pysimplecalc-1.tar.gz

Download URL pysimplecalc-1.tar.gz
Size 8.7 kB
Tags Source
SHA-256 checksum
How to use checksums
f711689a6c0aaec1f6c0254bd627e8ecdc52176e34e9fe80adab7f159d07dd6d
BLAKE2b-256 checksum
How to use checksums
045dd6ffc42352b38075ce718c40be6ec8550942a3d9539c61be55c286156ee4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/39.0.1 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page