And it executes twice when the first run.
Because calling import aaa
, will execute all the code in aaa
, and thus it will call the aaa()
function. then calling reload(aaa)
will re-import aaa
, so it will run all of the code in it again.
How can I prevent that?
Just remove the reload(aaa)
, I really don't see why you have it there in the first place, it's very seldom needed.
I don't also understand why you have you're code organized like that in the first place. You should almost certainly have them be like this:
import maya.cmds as cmds
def aaa():
blah... blah...
from aaa import aaa
aaa()