Python Classes and Modules

From Derivative
Jump to navigation Jump to search

The following list of important Python classes and modules is roughly grouped together by subject.

Python Reference has an alphabetical list of all TouchDesigner Python pages on this wiki.

Operator Related Classes[edit]

The following classes are Python interfaces for operators and objects that operators use. Individual operator classes (e.g. TextTOP Class and RampTOP Class) are not listed but do exist in the td module, and links to each can be found here or by clicking on the Python Help button in their parameter dialog. These classes are found in the td module so do not need to be imported.

Helper Classes[edit]

The following helper objects are part of the td module and can thus be accessed anywhere, including expressions, without imports (e.g. absTime.frame).

Standard Python Modules[edit]

The td module also automatically imports a number of helpful standard modules, allowing them to be accessed in expressions through their namespace (e.g. math.cos(math.pi)):

  • collections - container datatypes
  • enum - support for enumerations
  • inspect - inspect live objects
  • math - mathematical functions
  • re - regular expression operations
  • sys - OS specific data and functions
  • traceback - stack utilities
  • warnings - warning control

TouchDesigner Utility Modules and Python Utilities[edit]

The following contain extended Python utilities for use with TouchDesigner.


3rd Party Packages[edit]

The following 3rd party packages are automatically installed with TouchDesigner. They are not in the td module, so must be imported explicitly to be used in scripts. The name in parentheses is the actual package name used (e.g. to use OpenCV, write this at top of script: import cv2). For information on adding or installing other Python modules, see Importing Modules.

  • asn1crypto (asn1crypto) - Parsing and serializing ASN.1 structures.
  • attrs (attr) - Classes without boilerplate.
  • Certifi (certifi) - Root Certificates for validating the trustworthiness of SSL certificates while verifying the identity of TLS hosts.
  • CFFI (cffi) - Interaction with C code.
  • Chardet (chardet) - The Universal Character Encoding Detector.
  • charset-normalizer (charset_normalizer) - A library that helps you read text from an unknown charset encoding.
  • Cryptography (cryptography) - High level recipes and low level interfaces to common cryptographic algorithms.
  • decorator (decorator) - Define signature-preserving function decorators and decorator factories.
  • OAuthlib (oauthlib) - Library to build OAuth and OpenID Connect servers.
  • opencv-python (cv2) - Pre-built CPU-only OpenCV packages for Python.
  • depthai (depthai) - Python bindings for C++ depthai-core library.
  • idna (idna) - Support for the Internationalised Domain Names in Applications (IDNA) protocol.
  • jsonpath (jsonpath_ng) - JSONPath tools for accessing and altering JSON structures.
  • jsonschema (jsonschema) - jsonschema is an implementation of the JSON Schema specification for Python.
  • MWParserFromHell (mwparserfromhell) - An easy-to-use and outrageously powerful parser for MediaWiki wikicode.
  • NumPy (numpy) - Fundamental package for scientific computing with Python.
  • OpenCV (cv2) - Open source computer vision.
  • packaging (packaging) - Package tools including version handling, specifiers, markers, requirements, tags, utilities. Used for version string comparison.
  • pip (pip) - pip is the package installer for Python. You can use pip to install packages from the Python Package Index and other indexes.
  • ply (ply) - Parsing tools for lex and yacc.
  • Pygments (pygments) - A syntax highlighting package written in Python.
  • pyparsing (pyparsing) - A library of classes that client code uses to construct parsing grammar directly in Python code.
  • pyrankvote (pyrankvote) - PyRankVote is a python library for different ranked-choice voting systems (sometimes called preferential voting systems) created by Jon Tingvold in June 2019.
  • pyrsistent (pyrsistent) - Pyrsistent is a number of persistent collections (by some referred to as functional data structures). Persistent in the sense that they are immutable.
  • PyYAML (yaml) - YAML parser and emitter.
  • Requests (requests) - The only Non-GMO HTTP library for Python, safe for human consumption
  • Requests OAuthlib (requests_oauthlib) - Easy-to-use Python interface for building OAuth1 and OAuth2 clients
  • six (six) - Python 2 and 3 compatibility utilities.
  • smartypants (smartypants) - a Python fork of SmartyPants.
  • tabulate (tabulate) - Pretty-print tabular data in Python.
  • urllib3 (urllib3) - HTTP client.
  • whats-that-code (whats_that_code) - programming language detection library.

Installing Custom Packages and Modules[edit]

You can also install your own Python packages that are not included with TouchDesigner. For instructions, go here.