Sticky variable alternative

Yes that’s exactly correct, I find it much simpler for encapsulating local persistent/dynamic logic (than sticky).

I’d advice against using global and instead either have class methods/functions input, return and overwrite (append, manipulate, whatever you need) persistent variables you’ve instantiated within the if "foo" not in globals(): scope. Remember, this data can be anything. Leading to the second option: instantiating instances of your custom class as persistent variables, and then calling methods on these. I use this design a lot for writing dynamic system such as this one:

https://www.instagram.com/p/BlIg3K8HEcW/

Where the car “agents” is a list of class instances i’ve instantiated using this method, and than I call a drive() method on these each time the component updates. When resetting the system I then wipe/re-instantiate all the cars like so: