It looks like the exec() function is doing something here.
If you run the same script from the python source editor it sets the expression properly.
I dont have a solution for this case, but what i would do is make the subnet into hda and call the script from hda module so i can avoid the exec function.
Im too interested to know why this doesnt work when calling a script with exec() and how to fix.
Waiting for the experts!
import hou switch = hou.node("/obj/geo1").createNode("switch") exp = "$F4" switch.parm("input").setExpression(exp)