Resources For Learning Python

With some Covid-induced time off recently, I’ve made a concerted effort to try and learn Python. I’ve tried several times before and it has never really stuck, but I’ve always felt that I should be able to grasp it. So I was determined to use this time productively and crack it this time.

Luckily, there is a huge number of resources out there online these days and I’ve definitely got further than I’ve managed before. I’m still not nearly as good as I’d like to be, but I’m starting to feel like I properly understand the fundamentals now.

I decided I should make a collection of the resources that I’ve found helpful over the past couple of months. Hopefully you will find them useful too.

As well as this post, I have also started a collection of links to these and other coding resources here, which I will try to keep adding to. And I have started my own collection of code snippets here. I decided to make each one a separate post, so it is easier to search and I can add a little more detail to each one.

Python for Nuke 101

The first big help was Python for Nuke 101 by Ben McEwan. This is a great introduction course. Ben covers all the Python basics that you need to know, but, unlike a lot of the beginners Python courses, he is instantly approaching it from a VFX point of view. The classes are detailed, but easy to follow. The examples are useful and relevant. He provides great documentation to go along with the videos and the challenges that he sets after each course push you just enough, without being so hard you feel hopeless.

It’s a paid course, costing $49.99 USD, but it is totally worth the money.

Python For The Anxious CG Artist

Nelson Lim has created a great series of short YouTube videos that clearly explain Python concepts.

Python Start Kit – Attila Gasparetz

Attila Gasparetz has created a collection of simple but useful examples of code samples and put them together in this really easy to follow page.

He also has a great collection of useful Tcl (Tool Command Language) code conditional statement snippets here. And a great collection of useful Tcl code examples for displaying and modifying text here.

Adam Teale Code Snippets

Adam Teale has a large collection of code examples that cover all kinds of operations here.

The Foundry

The Foundry are the developers of Nuke. They have lots of useful training and documentation on their website.

Their Developer’s Guide has lots of good examples of how to achieve many of the things you’re probably going to want to try.

And the API reference guide is pretty ugly, but includes all the information you could possibly need to know about all the Python functions included in Nuke.

Codewars

Codewars is a great site for practicing your general Python. Once you create an account, you can choose Python from the many, many, coding languages to practice here. When you begin, you are given a default Kyu rating, which you can improve by taking part in user-generated challenges, called Katas.

The challenges have a description of what your code needs to do, and some example tests that your code will have to complete. You can write your code in a fully interactive IDE (Integrated Development Environment) in the browser, and test the code against the test examples. Once your code passes the example tests, you can hit the Submit button for the first time. This will run your code through many more tests that you can’t see. If it fails any of these tests, you will get an error message so you can work out what you need to fix.

Once your code passes all the tests, you can hit the Submit button a second time. Now you will be able to see everyone else’s answers. The answers are grouped into similar solutions and each user can vote on each solution as either ‘clever’ or ‘best practice,’ so you can see how other people work. You can also learn new Python functions that you didn’t know existed from other people’s answers.

These Kata challenged are rated in terms of difficulty, so you will only be assigned challenges that match your level, and once you have successfully completed enough Kata of one level, your Kyu ranking will be increased.

Seeing other people’s solutions, and reading the comments below them, is a great way of learning. I am constantly submitting solutions with 20 or 30 lines of code, only to see that most solutions are just two lines long.

The exercises are not relevant to VFX, but they are great for learning the basics of Python and how to think about coding in different ways.

I find doing one of these challenges each day is a great way to keep me thinking about Python and discovering new functions or ideas.

You can see my Codewars profile here.

Codeacademy

Codeacademy is similar to Codewars, in that it has an in-browser interactive IDE for writing your code, and it tests your code to see if you passed the challenge, but the challenges are much more structured. Each challenge builds on the previous one. I haven’t used Codeacademy as much as Codewars, because by the time I tried it, I’d learned the basics already. Plus, I liked being able to see other people’s solutions in Codewars. However, Codeacademy looks like a great place to start for beginners.

The Atom Nuke Package

This isn’t a learning resource, but a helpful tool. I’ve been using Atom as my IDE to write my Python code, and I recently installed the atom-foundry-nuke package, which allows you to run the code you are writing in Atom directly in Nuke, without having to copy and paste it over to the Nuke script editor. I have written a longer piece about setting it up and a couple of gotchas here.