Hello all,
I’m really new to Python (I’m used to code with C# and JS), and the indentation is driving me crazy.
Too many times, when I write some code in Textporter (RMB → Edit Contents in Textporter) I get several errors about the indentation, most times when I copy and paste, and Textporter does not notify anything, it’s just like Notepad.
I could open the script in VsCode, a real IDE, but due to how TD manage the scripts internally it’s a nightmare to open, close, re-open each script everytime.
Maybe this is not the best place to ask about that, and maybe I should learn Python a bit before to make questions on that, but all you guys use Textporter to write code in TD, just as it is, or maybe there’s a much better solution?
Many thanks!
Hi,
One of python’s fundamental design goals was to be more readable than other programming languages. As a result, it uses tabs and indentation to define scope and throws errors if, for example you use a tab to indent one place, and then some spaces to indent elsewhere.
Using an external editor for TouchDesigner python programming is how most of us that spend a lot of time doing it do just that. I find that TD’s ability to detect file changes is pretty good and, when using vscode can usually make updates freely in the text port or in the external editor and have them track consistently.
If you are having issues with the workflow of managing multiple python files, you may want to externalize the python, in other words create .py files and bring them in using fileinDATs and/or using the “Sync to file” option on various DATs. This will allow you to open the folder using your IDE and easily work on the files without having to manually go into each dat and edit them.
Python and related workflows are a well covered topic on this forum. Please feel free to ask more questions if needed.