Project

General

Profile

Actions

Python Training

what is a python module?

A module is a file containing Python definitions and statements.
The file name is the module name with the suffix .py appended.
Within a module, the module's name (as a string) is available as the value of the global variable name

what is a python package?

A Python module which can contain submodules or recursively, subpackages. Technically, a package is a Python module with an path attribute.
A traditional package, such as a directory containing an init.py file
Namespace packages may have no physical representation, and specifically are not like a regula r package because they have no init.py file.

in Vesper, each sub module is a package, please remember add init.py to the submodule and submodule/python, submodule/export.
in the init.py, you could export some class to this package

Recommend way to import a module in Vesper

In release version, we will encrypt the python code which may cause some unexpected issues, so we recommend to import a vesper module by:

from xxx.yyy.zzz import aaa

xxx is the submodule name, yyy could be python or export, zzz is the script under xxx/yyy

Doc and Reference:

Python Decorator: https://www.geeksforgeeks.org/decorators-in-python/
Python Coroutines: https://docs.python.org/3/library/asyncio-task.html
Python C++ interaction by pybind: https://pybind11.readthedocs.io/en/stable/basics.html

Updated by jun chen 3 months ago · 2 revisions