Cleaning PYC Files

When I first started writing Python scripts for Maya I ran into a problem where changes to scripts weren’t making their way into Maya. A little sleuthing uncovered the cause – PYC files, Python compiled file.

What happens is Maya creates a PYC file for a script when that script is first run, but if changes made to that script don’t trigger a recompile by Maya. This causes a situation where your script, when executed, preforms the previously compiled version. My solution was to create a function that searches a directory structure, in this case my masdevallia script folder, for PYC files and deletes any that are out of date. I call this script with my file. This way whenever I want to update the PYC files all I need to do is restart Maya.

Here are the required functions.