Improving Python Development for TouchDesigner Projects

Topics

Types of Python usage in TouchDesigner

Small snippets of code

Little bit of Python

Complex systems and infrastructure

So many Pythons!

IDEs and why they’re great

Some benefits of IDEs

Autocompletion in PyCharm
Static analysis warnings in PyCharm
Static analysis warnings in PyCharm
Static analysis in PyCharm

Which IDE to use

Problems with using IDEs for TouchDesigner projects

Problem 1: Code hidden in binary files

Hex code shown in PyCharm
Hex code shown in PyCharm
There may or may not be a DAT full of Python hidden in there. No one will ever know.

Problem 2: Built-In objects

PyCharm: “You keep saying ‘op’ as though I’m supposed to know what that means, which clearly I do not.”

Making TouchDesigner projects work well in IDEs

Create a project

Keep code in external files

Extensions

Shared library modules

Shared library modules vs component-specific code

Dealing with small code snippets in large projects

def cook(scriptDat):
ext.ThingManager.BuildThingTable(
scriptDat, someParam=scriptDat.par.Whatever,
anotherThing=op('other_stuff'))

Stub files

# noinspection PyUnreachableCode
if False:
# noinspection PyUnresolvedReferences
from _stubs import *

Type hinting

Configuring your IDE to recognize the stubs

Importing and using the stub files

# noinspection PyUnreachableCode
if False:
# noinspection PyUnresolvedReferences
from _stubs import *
try:
op
except NameError:
from _stubs import *
try:
TDF = op.TDModules.mod.TDFunctions
except NameError:
from _stubs import TDFunctions as TDF

Where we go from here

Tekt is a programmer and visual artist, who has been creating generative visualization systems in TouchDesigner since 2012. https://instagram.com/t3kt

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store