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
this will import need functions and classes
mf -i main.py -m demo -a
- -i: input file
- -m: modules or keywords in modules
- -a: get all code from source file
then, demo's functions will merge into one.py
PS: the code you need merge from extra module must in from ... import ... statements
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
Release history Release notifications | RSS feed
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.7.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file merge_functions-0.0.7.tar.gz
.
File metadata
- Download URL: merge_functions-0.0.7.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.7 Darwin/21.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3b0659b420f8572deddce1371825aa444163c983062b3dabbd6ac04e6695110 |
|
MD5 | ad6d3099f7f0f7f5692eb29a9a04f5f1 |
|
BLAKE2b-256 | 99aa568416749abc9a830915abce7a42746c2eb0d622054ef4a1d4fbe1fba7cb |
File details
Details for the file merge_functions-0.0.7-py3-none-any.whl
.
File metadata
- Download URL: merge_functions-0.0.7-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.9.7 Darwin/21.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9c815161f286b33cc20d733f15ecdd59f69548cf1a2251e0df90bb1e277c7a8 |
|
MD5 | 764005cc8cd890457053c8e908e264b8 |
|
BLAKE2b-256 | 1824732faac41681f7f21339197946422b1e2e62fb0f01a5bf118fae301bfc56 |