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 fileTextureName (ftn) attribute of all the file nodes in the scene:

>>> for f in'file'): ... f.ftn.set(f.ftn.get().lower()) ...

Get Practical Maya Programming with Python now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.