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
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.5.tar.gz
(4.7 kB
view details)
Built Distribution
File details
Details for the file merge_functions-0.0.5.tar.gz
.
File metadata
- Download URL: merge_functions-0.0.5.tar.gz
- Upload date:
- Size: 4.7 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 | 1cd82cb84031bce8d258cf4b6b939a5c527db23167327be23932d876e42d4d58 |
|
MD5 | f03d2e501a223dbe44203bff661edfa5 |
|
BLAKE2b-256 | e413b56ee60eb6cc59b9227ee212cc8acf193111df2b4c50f5796d7e9a6ab337 |
File details
Details for the file merge_functions-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: merge_functions-0.0.5-py3-none-any.whl
- Upload date:
- Size: 6.1 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 | eee491109aafb9dcfaed78c8968e857f02bedb63bc8943e69b0aaa0a2103fec0 |
|
MD5 | 0eb68fa110fad92fe13f427face4a0a2 |
|
BLAKE2b-256 | ed55c2d4de07dc8ddbbd210431015d1bc8caf6b6e042f76b3f9256427b3c6f9d |