Matthew Ragan | matthewragan.com
Whoa nelly! Welcome to a set of examples helping you get started with Python 3 in TouchDesigner. With any luck you're either new to TouchDesigner, or Python. If, however, like a growing number of artists you happen to be new to both of those things this is for you. Don't get me wrong, this is likely to be helpful to lots of folks, but if you're new to programming and feeling a little intimidated by the text port and writing scripts this should help you feel a little better about the world. Examples here will run the gamut of the mundane to the interesting, so don't be surprised if you find yourself a little bored while you're noodling around these examples. That's okay, these examples are here for you to come back to and look through at your own pace.
Many examples here come from the lessons I learned by going though the brilliant Zed Shaw's book - Learn Python the Hard Way. I can't recommend this book / ebook enough for those of you new to Python. Read it, re-read it, re-re-read it. It's definitely worth going through several times.
Happy Programming
As an additional quick note - these examples were oringally set up in 088. 099 has a few changes to the way python is being used, especially when it comes to executes. I'm slowly porting over these to 099, but for now you'll find that there's an 088 version of this project in the directory called 088.
Overview
Printing out lines isn't especially interesting on the face of it. That being said, this is one of the most powerful places to get your bearings. I almost always start any python related task by printing out bits of pieces of what I'm up to. It lets me see into the otherwise invisible process of code execution. Many folks will swear by this or that debugger, but at the end of the day your best debugging tool is just printing out what's happening. Learning the ins and outs of printing will also transfer to a number of different bits and pieces along the way. We'll start here as a way to get a solid handle on a few basic elements.
Overview
There are lots of resources on the web that describe variables better than I might:
- Variable - Computer Science
- Python Programmingg
- Python Basics
The essential idea here, however, is that you have something that you want to reference by name. That something might be a sentence, it might be a quantity, it could be anything really. Again, it's more important for us in this moment to consider that our something (whatever it is) happens to be a piece of information that we want re-use.
Overview
References are one of the engines of TouchDesgner. They're how we connect elements, and move information between operator families (and many other things as well.) I've written a good chunk already about understanding references - check out understanding referencingg, and understanding referencing part 2 - so I'm not going to do my best not to revisit all of that same information.
I do, however, want to look at referencing from the stand point of Python. The most important thing we might do is understand the anatomy of a python expression used in as a reference to another operator.
Overview
Logical statements are profoundly helpful for us when we're trying to convert an idea from what we understand, into something that a machine can interpret and act upon. Keeping that in mind, we need ways to distill ideas to their most fundamental pieces. What on earth do I mean? Well, we might think about ideas like greater than '>' , less than '<' , equal to '==' , and not equal to '!='. Further, we need to consider how we indicate when something might happen. This this set of examples we're going to focus on 'if' and 'else', as well as 'if' and 'elif' statements. What does all of that mean, well lets dig in and find out.
Overview
Short description here
Overview
Short description here
Overview
Short description here
Overview
Short description here
Overview
Short description here
Overview
Short description here
documentation written in markdown