Import Packages and Modules
The module cadwork is to be loaded into the namespace at any time. This module is needed for many processes.
import cadwork
Import packages
As CPython is used in cadwork, it is possible to work with external modules. The modules included in Python as standard can be integrated normally by loading the modules.
1 2 3 4 5 6 7 |
|
Import external packages
For external modules, their path variable must be added to the system.
sys.path in Python
Sys is a built-in Python module that contains parameters specific to the system i.e. it contains variables and methods that interact with the interpreter and are also governed by it.
sys.path sys.path is a built-in variable within the sys module. It contains a list of directories that the interpreter will search in for the required module.
When a module(a module is a python file) is imported within a Python file, the interpreter first searches for the specified module among its built-in modules. If not found it looks through the list of directories(a directory is a folder that contains related modules) defined by sys.path.
source: GeeksforGeeks
Initializing sys.path
By default, the interpreter looks for a module within the current directory. To make the interpreter search in some other directory you just simply have to change the current directory. The following example depicts a default path taken by the interpreter:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|