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

Uploaded Source

File details

Details for the file CustomOperators-0.4.tar.gz.

File metadata

  • Download URL: CustomOperators-0.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.8.5

File hashes

Hashes for CustomOperators-0.4.tar.gz
Algorithm Hash digest
SHA256 fb2dce1bf05e99d7eaef3d0bc48b5d8dbfa7ba702403036958bcd47e012f2b78
MD5 3d1a05db3dc18fb9a0edc92aefe0cc24
BLAKE2b-256 eec0d5debd5386addb25cfc033dda02b9c668cab6120fac6f14cda4912f09a44

See more details on using hashes here.

Supported by

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