# Is there a reason why handler functions are added differently from custom driver functions?

If I add a handler, I use:

bpy.app.handlers.handlertype.append(captainFuture)


If I want to remove it, I usually use the cheap way out since I still haven't learned to do it properly (I was young and I needed the money):

bpy.app.handlers.handlertype.clear()


Usable hack on a remote island but if by chance any addon or script uses the same handler, then disaster ensues.

Now, with drivers it's so much easier for this addled brain of mine:

Creation:

bpy.app.driver_namespace['curtis'] = captainFuture


Deletion:

del(bpy.app.driver_namespace['curtis'])


Nothing to remember but a string and a location.

Is there a binding reason why both approaches are different? Or asked differently and selfishly: Why not use dictionaries all the time?

Handlers are callback handlers that work on application level. Drivers work on data level. What does this mean?

app.handlers also work without having any data to work with. For drivers you will always need to add the driver to existing data in blender. For example an attribute on your object.

The app.driver_namespace contains some value modification functions you can use within your drivers. By itself it doesn't do a thing. It needs to be triggered by the animation system.

def mul2(value): return value*2
bpy.app.driver_namespace['my_function'] = mul2


Now you can use this function inside a driver python expression

#my_function(var)