Python Training » History » Version 1
jun chen, 03/10/2025 12:12 AM
1 | 1 | jun chen | # Python Training |
---|---|---|---|
2 | |||
3 | ## what is a python module? |
||
4 | |||
5 | A module is a file containing Python definitions and statements. |
||
6 | The file name is the module name with the suffix .py appended. |
||
7 | Within a module, the module's name (as a string) is available as the value of the global variable name |
||
8 | |||
9 | ## what is a python package? |
||
10 | |||
11 | A Python module which can contain submodules or recursively, subpackages. Technically, a package is a Python module with an path attribute. |
||
12 | A traditional package, such as a directory containing an init.py file |
||
13 | Namespace packages may have no physical representation, and specifically are not like a regula r package because they have no init.py file. |
||
14 | |||
15 | in Vesper, each sub module is a package, please remember add init.py to the submodule and submodule/python, submodule/export. |
||
16 | in the __init__.py, you could export some class to this package |
||
17 | |||
18 | ## Recommend way to import a module in Vesper |
||
19 | |||
20 | In release version, we will encrypt the python code which may cause some unexpected issues, so we recommend to import a vesper module by: |
||
21 | ``` |
||
22 | from xxx.yyy.zzz import aaa |
||
23 | ``` |
||
24 | xxx is the submodule name, yyy could be python or export, zzz is the script under xxx/yyy |
||
25 | |||
26 | ## Reference: |
||
27 | Python Decorator: https://www.geeksforgeeks.org/decorators-in-python/ |
||
28 | Python Coroutines: https://docs.python.org/3/library/asyncio-task.html |
||
29 | Python C++ interaction by pybind: https://pybind11.readthedocs.io/en/stable/basics.html |