Python custom classes and objects

Is it possible to create a python script that contains a class definition, and then create instances of that class and keep them persistant in memory? What is the best way to do something like this?

I could store data using storage, but that is limited to dictionaries.
Object instances are a bit more elegant as they can contain functions for retrieving and organizing large complex data structures, such as combinations of lists, dictionaries, and properties.
The problem is that the object instances are not persistent (data is lost after each frame).

My situation:
I’m trying to create a custom 3D form generator, similar to L-Systems.
I love the L-systems node, and use it a lot, but it does have limitations, and I’d like to greatly expand beyond it. So I’m attempting to make a python script that will do what I would like. The parser generates a ton of data, which would be awkward to store in a table dat. But storing it in a python custom object would be very elegant.
I’m open to other alternatives, including storing the data in extensions. But I haven’t yet determined if that will work. Thought I should ask first before reinventing the wheel.

thanks in advance
Thomas

You might check out Extensions to see if this will help with what you’re after:

[url]http://derivative.ca/wiki088/index.php?title=Extensions[/url]

[url]https://matthewragan.com/2015/07/05/touchdesigner-understanding-extensions/[/url]

yes! that works!
Thank you Matthew, for your great explanation of Extensions.
This does exactly what I need.
It stores the instance of the class, and keeps it’s properties persistent in memory.
I can set and get various properties, including dictionaries, lists, properties and lists of dictionaries.
Can also create and call custom functions, which can set params within the container.
This is really powerful.
In conjunction with the replicator, we finally have real OOP in touch, where we can have instances of geo that can contain custom properties and functions that can be called and controlled from other scripts.
wonderful! This is what I’ve been waiting for.
thank you for making this so clear. If only they would hire you to flesh out the manual.

it really works. This post was really a help for me.

Extensions are pretty killer. They’re a part of just about everything I do now.

Throw in some custom parameters and you’re really off to the races.