dynamicer
is a Python library designed to dynamically load and execute Python modules and C dynamic libraries. It provides a convenient way to import and run Python functions or classes and C functions from specified files dynamically.
- Import Python functions or classes dynamically from a module
- Run Python functions dynamically from a module
- Run C functions from a dynamic library
- Customized exception handling during service execution
- Cross-platform support for Linux and Windows
You can install dynamicer
using pip:
pip install dynamicer
from dynamicer import dynamicer
dp = dynamicer()
func = dp.import_py("module_path", "function_name") result = dp.run_py("module_path", "function_name", *args, **kwargs)
dp.run_c("dll_path", "function_name", *args, arg_encoding="utf-8")
The library uses Python's built-in logging module. You can enable or disable logging and set the logging level when initializing the dynamicer instance.
- ModuleExecutionError: Raised when there is an error during the module execution phase.
- FunctionLoadError: Raised when the function cannot be loaded from the module or library.
- FunctionCallError: Raised when there is an error calling the function.
Please refer to the CONTRIBUTING.md for information on how to contribute to dynamicer.
This project is licensed under the MIT License - see the LICENSE.md file for details.