Hello San,
As I mentioned earlier this script when saved and then imported as a module was not able to print out the desired object names, I apologize if I was not clear at first instant. The script works fine if one will execute this in the Maya script editor, however it does not print out the window and the polygon objects on the screen when imported as module.
Okay, I figured out later that this was due to the fact that temp_var and a_window variables were not getting updated in the global namespace, as you mentioned that their scope remains local to that function.
A weird case though was, when I called a function with a single argument it got printed ok.
Anyways, with all that said and done, Achayan introduced me to the wonderful function wrapper modules called functools ,it has a nice function called partial.
here is a working sample of the code:
Code:
import maya.cmds
from functools import partial
def im_PrimaryFunc():
imSecondary_func()
def imSecondary_func():
a_Window=maya.cmds.window(title="Something")
a_layout=maya.cmds.columnLayout(adj=1,rs=10)
temp_var=maya.cmds.createNode("polySphere")
maya.cmds.button(label="call_aFunc",align="center",command = partial(a_calledFunc,temp_var, a_Window))
maya.cmds.showWindow(a_Window)
def a_calledFunc(arg00,arg01, part):
print(arg00)
print(arg01)
im_PrimaryFunc()
This way of creating a module makes the process way more safer by avoiding hassle of managing global variables in the program.