Skip to main content

Custom operator implementation in Python

Project description

This module allows you to use operators specified by you.

Setup

To install the module, run: sudo pip3 install CustomOperators

Usage

To import the module, use

import CustomOperators

To create an operator, use the CustomOperators.Operator decorator

Examples:

2 operands:

import CustomOperators

@CustomOperators.Operator("§")
def Power(left, right):
    return left**right

1 operand:

import customOperators

@CustomOperators.Operator("!")
def Negate(base):
    return not base

To run a script that uses the new operators, import it with CustomOperators.ImportModule

Example:

#Module.py

def run():
    print(4§5)
#__main__.py

import CustomOperators

@CustomOperators.Operator("§")
def Power(left, right):
    return left**right

CustomOperators.ImportModule("Module")
Module.run()    #Output: 1024

For more information about usage (operator overloading, operator rules), check out the wiki page

Project details


Release history Release notifications | RSS feed

This version

0.4

Download files

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

Source Distribution

CustomOperators-0.4.tar.gz (3.6 kB view hashes)

Uploaded Source

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