pythonHere’s a script I wrote for adding sub-directories of paths I’ve already added to the sys.path in my userSetup.py.

I’m just starting to code seriously in python and it seems like just getting everything to work right in Maya without a lot of fuss is pretty daunting for a beginner with little outside help except for the internet and a couple books.

As my Script Repo develops over time, I don’t want to have to keep worrying about PYTHONPATH having everything in it so I tell it where the root directories are and this script does the rest. ;)

Hope somebody finds this helpful!

import sys
from os import walk
path = ja_python_paths
for p in path:
 for root, dirs, files in walk(p):
 if p is not root:
 sys.path.append(root)

#You can add an optional print statement at the end
#to see what it's doing...

if p is not root:
 print 'adding', root, 'to sys.path'
 sys.path.append(root)