Before, in the absence of an application that found the VS tool Python Project search paths, for example: If the project's file directory is as follows:
maintest/maintest.py you want to use the common/tools.py file, you have to add such code to the code in maintest.py:
Import SYS Import OS from Import = Os.path.join (Os.path.dirname (Os.path.dirname (__file__"\common " # Add the directory where tools resides to path Import Tools Print Path Print TOOLS.A
In this case, the code is not concise enough.
Or use the modular idea, the common into a module, put into the maintest/directory, maintest.py file import common.tools module. The project file structure will become as follows:
Maintest
--maintest.py
--common
----tools.py
----__init__.py
This project file structure looks confusing (not human-friendly)
Or you can use Xxx.pth to append the directory where you want to import the module (file), but in this case, your team's small partners unknowingly execute the script will be error ... You must add the same. PTH in the same directory.
Now, just add the parent folder of the file you want to import into search Paths
Well, now maintest/maintest.py want to use common/tools.py directly import module, inside the mechanism has time you can dig into it.
Import SYS Import OS from Import = Os.path.join (Os.path.dirname (Os.path.dirname (__file__#path.append ( Parentdir + "\common") # Add the directory where tools resides to pathimport toolsPrint path Print TOOLS.A
Amazing discovery vs Tools Python Project search Paths application