Module Import#
When multiple script files need to work together to accomplish complex tasks, other modules can be imported. Syntax:
1# Import
2use <module_path>
3use <module_path> as <name>
4# Usage
5<module_name>.<func_name>Please Note
Module names must be unique: All imported modules (including descendant modules) cannot have the same name. If there are duplicates, please rename them using
as name.This is a trade-off between performance and convenience; for higher performance, we have decided to accept this minor inconvenience.
Modules should be used as utility functions: When importing a module, only
fndefinitions andusestatements will be read; statements outside of function definitions will be ignored to avoid unintended code execution.
Other Import Methods#
- import Statement
Execute a script in a new environment:
1# Import 2import <script_path> - include Statement
Execute a script in the current environment:
1# Import 2include <script_path>
Both of these methods will execute the script, while the use method will not execute the script but only import functions. In most cases, it is recommended to use the use method only.