Skip to main content

Stacker: RPN Calculator in Python

Project description

日本語 (Japanese)

Stacker: An RPN Calculator

Stacker is a powerful Reverse Polish Notation (RPN) calculator built with Python, featuring basic mathematical operations and extensibility through plugins.

Installation

Prerequisites:

Ensure Python 3 is installed.

Installation Options:

  • Via pip:

    pip install pystacker
    
  • From source:

    git clone git@github.com:remokasu/stacker.git
    cd stacker
    python setup.py install
    

Feedback and Contributions

Feedback and contributions are welcome. Please submit issues or suggestions on the Issues page.

Dependencies

Stacker uses external libraries like NumPy and Python Prompt Toolkit. Ensure these are installed:

pip install numpy prompt_toolkit

Usage

Run Stacker:

stacker

Or:

python -m stacker

Stacker supports standard arithmetic operations (+, -, *, /) and advanced functions (sin, cos, tan, etc.). Users can input commands in RPN format and extend functionality using custom plugins.

Input Examples

Stacker allows for straightforward RPN input. For example:

  • Single-line input:

    stacker:0> 3 4 +
    [7]
    
  • Multi-line input:

    stacker:0> 3
    [3]
    stacker:1> 4
    [3, 4]
    stacker:2> +
    [7]
    

Running Scripts

Stacker scripts can be created in *stk files. To run a script, simply execute it with Stacker. For example:

stacker my_script.stk

Creating Plugins

Create custom plugins for Stacker using Python:

  1. In the plugins directory, create a new Python file for your plugin (e.g., my_plugin.py).

    stacker/
    │
    ├── stacker/
    │   ├── plugins/
    │   │   ├── my_plugin.py
    │   │   └── ...
    │   │
    │   ├── data/
    │   ├── stacker.py
    │   ├── test.py
    │   └── ...
    │
    └── ...
    

    Adding your plugin here and reinstalling Stacker will apply the plugin permanently.

  2. Alternatively, create a plugins directory in the directory where Stacker is executed. This allows you to use plugins without reinstalling Stacker.

  3. Define required functions or classes in your plugin file.

  4. Add a setup function to register these with Stacker.

Example:

from stacker.stacker import Stacker

def function(a, b):
    # Do something

def setup(stacker: Stacker):
    stacker.register_plugin("command", function)

Documentation

For more detailed documentation, please refer to stacker/docs.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

pystacker-1.4.6-py3-none-any.whl (38.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page