Did you ever wonder what Python does with all those variables and functions you write in the Maya script editor? No? Well I am going to tell you anyway. I recently refered to the Maya Script Editors Python global scope or main namespace as the main module to a friend. He said that I must have been tired and meant something else, but I didnt and here is why.
Type in and execute the following code into your script editor in a Maya Python tab:
print __name__
Which will print:
__main__
When you print __name__ in a module it will give you the namespace of the module itself. So why did printing __name__ work inside of the Script Editor? Now write a quick function and execute it in the Script Editor:
def test():
"""this function is a test"""
print "test"
Next type and execute the following line:
help(test)
#Result:
Help on function test in module __main__:
test()
testing
Recent Comments