nodepath.setTag() to save class

Is there a way to save a class in a tag, and then retrieve it later? For example, a collisionNode that points back to a class when clicked/collided?

for example:

#import direct.directbase.DirectStart
from pandac.PandaModules import *
import sys,random
from math import *

class test:
	def __init__(self): = NodePath(PandaNode('hi'))
		self.hi = 'hi''test',str(self))

t = test()
t1 ='test')
print t
print t1
print t.hi
print t1.hi    #fails

t and t1 appear to be the same things, but t is real and t1 is only a string. Is there a way to make t1 ‘real’?

You want setPythonTag() instead of setTag().

Note that when you do this sort of thing, setting a reference back to self in a NodePath referenced by self, you are creating a circular reference count, and that NodePath (and your class object) will never be destructed until you explicitly break that cycle, either by calling or by setting = None (or both).