All About Modules
Ryan Trowbridge & Adam Mechtley
Create modules, explore some built-in modules, configure PYTHONPATH, install an external IDE
While readers will have been using some modules up to this point (most notably maya.cmds), this chapter discusses exactly what modules are, how they work, and how import and reload() differ from the MEL source directive. While using some important built-in modules like math, os, and sys, this chapter also introduces readers to a variety of ways they can configure their Python environment. Finally, this chapter concludes with some brief information about two popular Python IDEs, WingIDE and Eclipse.
There are plenty of great IDEs out there that are not covered in the book. My personal favorite is PyCharm, which now also has a free version.
Errata for the First Edition
On p. 131 the section on userSetup scripts incorrectly states that “you may only have one userSetup script and it must be either a Python or a MEL script—you cannot have both a userSetup.mel and a userSetup.py script.” You may in fact have several userSetup.py scripts, and can use both .py and .mel scripts in conjunction with each other under some circumstances.
On p. 140 the section on setting up a systemwide environment variable for OS X advocates doing so in the launchd.conf file. Unfortunately, as of OS X 10.10, this method no longer works. See here for alternative suggestions that will achieve the same result.