Skip to main content

A simple calculator, able to parse quite complex expressions

Project description

What is simplecalc?

A simple calculator, able to parse quite complex expressions:

>>> from simplecalc import calc
>>> calc("2 + 3.5")
>>> calc("2 * log(100)")
>>> calc("sin(pi / 2)")
>>> calc("3 * 5!")
>>> calc("3 * 5! + ceil(sqrt(123) / ln(10))")
>>> calc("3**e  * 5! + ceil(sqrt(123) * ln(10))")

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)"

Project’s history

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

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

Project details

Release history Release notifications | RSS feed

This version


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for pysimplecalc, version 1
Filename, size File type Python version Upload date Hashes
Filename, size pysimplecalc-1.tar.gz (8.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page