In the python inside Maya group, Sylvain Berger wrote how he has organized his python scripts with Maya. This setup is very clean, simple and you just have to add one line in your Maya environment file:
Create a folder where you are going to save all your python scripts and add the path to your maya.env file.
PYTHONPATH = Z:/pythonScripts
Inside this folder create sub-folders (also called packages) for organize your scripts, like:
animation/
modeling/
rendering/
etc.
Now create an empty file in pythonScript folder and inside all the sub-folders and name them __init__.py to tell python that these folders should be included by the import command, so if you want to use a function located in a script from the animation sub-folder (animation package) you type the following:
from animation import animFunctions
then you can call the functions of these scripts
animFunctions.function1()
alternatively you can also rename the package in the import function
from animation import animFunctions as anim
then call the function using the name
anim.function1()
And that’s all. This is a copy/paste from the Sylvain Berger’s email, so all the credits goes for him.
Thanks Sylvain for the explanation.