Python Scripting for Compositors

Taught by Michael Morehouse

Course Number:
Software Version:
Python 2.6.1 
Original Run Date:
April 2009 
10 hours 29 minutes 
In the last few years Python has grown from being a rather obscure scripting language developed by a man with an intense love of Eric Idle to being the de facto standard for scripting applications in the post production domain. This new introductory class will focus on the fundamentals of python scripting, building up to quick, tactical tools that can be used by vfx artists in facilities large and small to make their lives easier and their financial masters happier.

As The Foundry's Nuke has been converted to a Python underpinning since the release of version 5.0 a great deal of interest has developed in existing and developing nuke artists for some understanding of the TD magic going on under the hood. Nuke is now an incredibly scriptable program with a very powerful set of core tools that can, in the hands of a compositor with a good basis in Python, dramatically improve the efficiency of many of the more redundant compositing tasks, and can even make the bit that remains a lot more fun in the process.

This course will spend a fair bit of time getting compositors with little or no programming / scripting knowledge up to speed; Python is very accessible to non-programmers and as you will learn a little Pythonic knowledge can go a very long way towards making your compositing life a lot easier. This course syllabus will likely change as we delve in and see how everyone does getting their feet wet. The last two lessons, especially, will evolve in response to the type of examples that you, the student body, would like to see and explore.

Suggested Text: Learning Python, 3rd Edition by Mark Lutz ISBN 0596513984
Python Scripting for Compositors
Watch our overview of the course

Class Listing

Class 1

The most basic Python program possible, followed by an introduction to all of the basic variable types, including Integers, Floats, and Strings.

Class 2

We expand on the basic numeric and string variable types presented in Class01, and continue on to the sequential variable types, lists and tuples. There is also some discussion of syntax and naming conventions.

Class 3

We finish introducing the basic python variable types with a discussion of Dictionaries. We then move on to program logic flow tools such as if / elif / else conditionals and for loops, while loops, and list comprehensions.

Class 4

Modules, use and abuse. Function definitions, namespaces, and variables both global and local / private. The Try statement and exception handling in general.

Class 5

Jumping into Nuke: basic customization through the and files. Folder structures and the basics of package importing. Good installation practices, followed by How to Break Nuke in One Easy Step ... and figure out how to fix it again.

Class 6

Beyond customization. Simple one off scripts to make changes to many nodes very fast, quick ways of finding things you thought were lost, and the dumbest thing you'll ever see Python do to Nuke (AKA Havoc for Fun and Profit). Some time will be spent on parsing external files to bring arbitrary data into Nuke and use it for something.

Class 7

The Top 10 Things you should know how to script in Nuke. Including a basic Panel GUI.

Class 8

A very brief introduction to Object Oriented Programming; this is an advanced topic, but it can really come in helpful when you start looking at expanding on the toolset you've already built above. Simple Classes, an understanding of inheritance, and a foundation in the world of OOP.

Class 9

The next two lessons will be dedicated to more advanced scripting examples that students request, as well as a good overview of docstrings and why they are your friend. More discussion of OOP is likely, as is a brief introduction to the Ethics of Scripting Well.

Class 10

Continuation of the previous lesson.