==========
A simple calculator library.
This module is now a Python package. You can install it using:
$ sudo pip install simplecalculator
Examples of usage:
* `simplecalculator.py` -- a command-line utility
* `tornadoweb.py` -- a TornadoWeb applications with a minimalistic RESTful API. Do you math with curl!
How?
----
Clone this repo and tests:
$ python -m unittest test
All good?
Usage (in your script)
-----------------------
1. Import `calculator`
2. Instantiate `SimpleCalculator()`
3. Call `run()` with the list of values, operands, and functions you want to process.
4. The history of operations, results, and unprocessed input is stored in `SimpleCalculator.log`.
Here's a short sample:
from calculator.simple import SimpleCalculator
c = SimpleCalculator()
c.run('1 + 1')
print c.log
If you want to read the state of the LCD (no kidding!), use
print c.lcd
Usage (on the command line)
---------------------------
Run:
$ ./simplecalculator.py -s "1 + 2 / 6 acv 1 + 1 / 33 fmod 0.01"
then
$ ./simplecalculator.py -s "1 + 2 / 6 acv 1 + 1 / 33 ceil fmod"
then
$ ./simplecalculator.py -s "1 + 2 / 6 acv 1 + 1 / 33 fmod 0.01 1 2 3 4"
This calculator is as forgiving as a simple desktop calculator, it will ignore what it does not know, try to compute what it can treating the given string as a list of keystrokes. You may see one or more `status` entries after the last result, that's intended.
Usage (via curl)
----------------
If you want to implement this alculator as a RESTful API, install [TornadoWeb](http://tornadoweb.org 'TornadoWeb') and run `tornadoweb.py', then use curl:
$ curl -X POST http://localhost:8888/v1/calculate -d '1 + 2 / 6 acv 1 + 1 / 33 fmod 0.01 1 2 3 4'
You can easily extend this calculator to support any number of one- and two-argument functions, search calculator/simple.py for `fmod` and `ceil` to see what modifications you need to make.
Why?
----
I got asked to provide samples of my work, proof I know Python, etc. This project is way more than what I was asked to deliver, but I had more time to spare. There is more coming.
Who?
----
Jacek Artymiak
Metadata
Release files for simplecalculator 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| simplecalculator-0.0.4.tar.gz | 2.8 kB | Without provenance | Details for simplecalculator-0.0.4.tar.gz |
Release files / simplecalculator-0.0.4.tar.gz
| Download URL | simplecalculator-0.0.4.tar.gz |
|---|---|
| Size | 2.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1d862b52bc21305ef7633e59be71aae233905c51846b8775b66afb0104fa6110
|
|
BLAKE2b-256 checksum How to use checksums |
69d83e50699faedb93a5818c962faefe81afdbbc2aa4a9ad55e6098f5416ece2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for simplecalculator 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.