Case 1: sys.path
if we want to load a module from a custom path instead of Maya default scripts directory
Example:
import sys
# add a new path to sys.path
# so Python will search the modules in the new path
# then you can import the module directly
sys.path.append('c:/test/testModule.py')
import testModule
Case 2: sys.modulesa dictionary mapping loaded modules and their names
Example:
# print out all modules and module names
for k,v in sys.modules.iteritems():
print k, v
No comments:
Post a Comment