I’m taking a poll of the python modules that TouchDesigner users have found useful in their work - aside from the one that we re-install like numpy. I want to make a list of modules for both new and experienced users, both familiar and not familiar with python. I’ll just start the list with one, haha:
os
[ This is following on a thread by ennui in 2014, but the world has changed since then. ]
Flask (This is a simple web server - which may already be addressed with the web sever DAT. That said, this is a lovely way to create web apps via python)
Those aside, it’d be great to see some extra helpers for additional support. Recently I’ve been doing a little work with a user to move data from TOPs to .ply files.
jijja - templating library - helpful for formatting HTML with temples
EDIT
Open3D - Open3D is an open-source library that supports rapid development of software that deals with 3D data.
I’d also use this as a quick moment to plug a nice virtual environment solution - or some handling for pip installs that land your project directory rather than in your OS or TD python libs. There’s also a great thread by @nettoyeur about package managment with poetry that might be worth adding to this conversation:
warnings create your own warnings or suppress warnings from other modules.
These ones are quite common just like os
argparse parse arguments for scripts csv read and write csv files glob easiest way to find files json read and write json, convert python objects to json math common math functions or constants like math.ceil and math.sin and math.pi multiprocessing In scripts outside of TouchDesigner, I prefer multiprocessing to asyncio for some tasks. I use Process, Pool, Manager, and Manager().Queue() random
random()
randint(0,10) ← random integer between 0 and 10, including 10
choice([“a”,“b”,“c”]) ← random single choice from list
choices([“a”,“b”,“c”], k=2) ← random choice of 2 items, allowing duplicates
Thanks so far… going forward, when you list a module, write a few words about what it’s good for, as most of us won’t know what it is, including me. thx
scipy - scientific computing, I just install this as a pre-req for sklearn below.
sklearn - some really cool stuff in here, I specifically make use of the vast clustering libraries for grouping large numbers of points into localized groups.
pyperclip - cross platform library for setting/getting clipboard data.
yaml - wasn’t this one included recently in 40k? can’t remember… anyways I’ve used this in the past for serializing python data that I can later re interpret back. Primarily I used it for saving/loading project data that I wanted humans to be able to read too.
Another good one I just discovered! Humanize takes data in various formats, time, file size, etc and converts it to a slew of different human readable formats.
dataclasses is great for creating data structures with named and typed fields, with support for constructor parameters, conversion to/from dicts, and metadata that supports things like serialization.
natsort · PyPI, lots of applications and different use cases, I have been using this library to sort path strings (path/to/folder, and path/to/folder/subfolder, etc) into hierarchy aware, and alpha-numerically correct lists/orders. Really useful for building object outliner modules and such things.