Was wondering if there is a less vigorous way of removing an item from the driver namespace, perhaps using pop() or popitem()?

import bpy

dns = bpy.app.driver_namespace
dnc = dns.copy()

# clear dns

#remake with any key beginning with "ST_" removed

for k, v in dnc.items():
    if k.startswith("ST_"):
    dns[k] = v


Looks like dns.update(...) is the go:

D.update([E, ]**F) -> None.  Update D from dict/iterable E and F.
If E is present and has a .keys() method, then does:  for k in E: D[k] = E[k]
If E is present and lacks a .keys() method, then does:  for k, v in E: D[k] = v
In either case, this is followed by: for k in F:  D[k] = F[k]

which gives me:

import bpy

dns = bpy.app.driver_namespace
dnc = {k:v for (k, v) in dns.items() if k.startswith("ST_")}


Both of these are ok for a 'startswith search', but seem overkill if I know the name of the item I want to remove.

del bpy.app.driver_namespace['driverFunc']

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

  • $\begingroup$ Lol as simple as that. $\endgroup$ – batFINGER May 16 at 12:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.