I have a script that watches for changes in another script, and re-runs the latter if it's changed. Gist here. It's run like this:
~/blender/blender-2.92.0-linux64/blender --python script_watcher.py -- test_group.py
It worked ok until I used the
reduce() function in the watched script - snippet here (
union() is a function that creates the union of two objects):
def all_union(first, *others, **kwargs): def _(a, b): return union(a, b) r = reduce(_, others, first) return r
then I get an error message like this:
NameError: name 'reduce' is not defined
I tried replacing the timer script with one that runs only once - like this:
import bpy import sys import os import traceback prev = "" curr = open(sys.argv[-1]).read() if not prev==curr: print("%s changed" % sys.argv[-1]) try: exec(curr) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() print(traceback.format_exc())
and it runs perfectly - no error.
So why is
reduce() not not working under the timer? or is the issue somewhere else?