How to set attributes in a Blender registered class dynamically?
As this relates to Sverchok, but more broadly to bpy's PyNodes interface, i'll chime in with the limited knowledge / experience I have.

No you can not trust that variables/properties added to an instance of a class will "stick" to the class instance. You can also not remove a property at run-time. In this sense Node classes are not like regular Python classes. If you dynamically add a property inside a function it might exist for the duration of a function call, but once execution leaves that function then the variable/property ceases to be associated with the class instance. The evidence that this is the case is what probably triggered the question in the first place.

The only things you can trust are the Properties that are included in the Class definition. I suspect this makes node instances more of a "known quantity" and reduces complexity of the PyNode back-end.

We (sverchok) however do use a not widely documented/explained feature for storing arbitrary data (not bpy.props tho..at least I have not tried..) in a class instance. We call it the node_dict. When used correctly The node_dict (class member) gets a unique key per class instance, and we can pass anything into the value.

def some_random_function():
    ...



class SomeNode(...):
    node_dict = {}

    def sv_init(self):
        node_dict[hash(self)] = {}

    def store_data(self, data):
        storage = node_dict.get(hash(self))
        if storage:
            storage['some_function'] = some_random_function

    def process(self, ..):
        storage = node_dict.get(hash(self))
        if storage and storage.get('some_function'):
            storage['some_function']()  # call it.


This is about as minimal i can go to show some of the mechanism for dynamic data storage. There are examples of defining a node class dynamically (the monad Class relies on it) but it's something that I consider obfuscation and possibly a sign of placing importance on the wrong things.

Of course it would be awesome to have more fine grained control over the parameters of properties at runtime like (name, min, max....dynamic operator tooltip), without needing to dynamically define/register/unregister nodes if you want to change a single property-definition.