Skip to main content

merge functions from other python files

Project description

Merge functions from other python files

this is a dirty way to merge functions from other python files into one python file in order to deploy fast.

install merge_functions

pip install merge_functions

how to use

if you want to import from current directory python file, you need set environment:

if you current path is: ~/code or D:\code

mac or linux:

export PYTHONPATH=~/code

windows

set PYTHONPATH=D:\code

help info

mf -h

simple example:

mf -i main.py -m demo
  • -i: input file
  • -m: modules or keywords in modules

then, demo's functions will merge into one.py

main.py below

from demo import add, subtract, multiply, divide
import json


def run():
    a, b = 3, 4
    result1 = add(a, b)
    result2 = subtract(a, b)
    result3 = multiply(a, b)
    result4 = divide(a, b)
    result_dict = {
        "result1": result1,
        "result2": result2,
        "result3": result3,
        "result4": result4,
    }
    print(json.dumps(result_dict))


if __name__ == "__main__":
    run()

demo.py below

def add(a, b):
    return a + b


def subtract(a, b):
    return a - b


def multiply(a, b):
    return a * b


def divide(a, b):
    return a / b if b else 0

Project details


Download files

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

Source Distribution

merge_functions-0.0.2.tar.gz (3.4 kB view details)

Uploaded Source

Built Distribution

merge_functions-0.0.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file merge_functions-0.0.2.tar.gz.

File metadata

  • Download URL: merge_functions-0.0.2.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.7 Darwin/21.5.0

File hashes

Hashes for merge_functions-0.0.2.tar.gz
Algorithm Hash digest
SHA256 2e5479d5900a7fd57615754cfa115578bcfb40fb8afd364207ec5d695c03f45e
MD5 9c46e48b92d08fd4ad183d28a95d2e83
BLAKE2b-256 27a5d21de100a7597f4fc9e60a1b7a5e80236f24e8b7aa12656c2e58c7a8d4ef

See more details on using hashes here.

File details

Details for the file merge_functions-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: merge_functions-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.9.7 Darwin/21.5.0

File hashes

Hashes for merge_functions-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3e3f8b961a79224e30ddbf173fb9d35f22edca8b942e9966e9be70870e39817c
MD5 094fb8e7c8fcf65e1b6b0c50b7709b2c
BLAKE2b-256 3de5c56b61a950c26d31ea7e0e7161127c8501c1a7f206618bd66d37237fa3ea

See more details on using hashes here.

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