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.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

merge_functions-0.0.3-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: merge_functions-0.0.3.tar.gz
  • Upload date:
  • Size: 4.1 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.3.tar.gz
Algorithm Hash digest
SHA256 4c665f63c12aa95fec520fc72f600842d541e0c7b49d6f34b3ea8c3409e12c9e
MD5 f84124fb8dab97f0e7bee653915d13d0
BLAKE2b-256 e79ed15669c790f410463bdd9d537cbd6ae3fa92b1496d89460d18fa3ab64cb2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: merge_functions-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 5.3 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9a01e0c2ef525493648dde06b9d8768e1181c8a2f583eb002de3065a92c54fe8
MD5 135d9fe06d401fd6c1d9fd142cc0f413
BLAKE2b-256 a1730f4b1604a0fac927b0a94e93d24870d084ddcc6bb472b7b9082fc304e764

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