Practical error handling in Maya
Most of these golden rules are true in Python in general, as well as most other programming languages with exceptions. However, using Python in Maya is a different environment. There are some additional tools and constraints available. In this section, we'll go through some of the unique problems we face in Maya, and what can be done to mitigate each problem.
Dealing with expensive and mutable state
The biggest problem with error handling in Maya is that its overall design significantly constrains the choices of any system built on top of it. Consider the following script that lowercases the
ftn) attribute of all the file nodes in the scene:
>>> for f in pmc.ls(type='file'): ... f.ftn.set(f.ftn.get().lower()) ...