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.6.tar.gz
(4.8 kB
view details)
Built Distribution
File details
Details for the file merge_functions-0.0.6.tar.gz
.
File metadata
- Download URL: merge_functions-0.0.6.tar.gz
- Upload date:
- Size: 4.8 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 | 94c579e0a1cd6c2f20226107543572ae2641d387fe02f5bb47f81b9759f3246d |
|
MD5 | 226dd1351febba46bd54f6223da00c37 |
|
BLAKE2b-256 | de3127b9070202e9b7ecd7900a95f142cb63d7e891efc63cd78ce85fce1ea940 |
File details
Details for the file merge_functions-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: merge_functions-0.0.6-py3-none-any.whl
- Upload date:
- Size: 6.3 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 | 5e3c7709e96892e17cf17e78295120a55e8a4c5fc168e03f55348a688fe01693 |
|
MD5 | 20f567bf09a322a1973895a463a2593f |
|
BLAKE2b-256 | 0b0acaa5020eddb09f33a747d16ebe599471f9c7ad3aa1f24e2157cf180b30bf |