Namespaces
 
 
 

In Python, all variables, functions and module names are in either the local namespace (restricted to a function) or in the global namespace. To see what names are available in the current namespace, type dir() in the interactive console.

The editor stores the Python global namespace. That is, all names that are available. When you execute a script, names in your script replace those in the global namespace. For example: in the interactive console define a string:

s = "mystring"

Create a new script and execute it (any script will do, even an empty one).

After this script executes, if you try to access your variable, the name is now undefined.

s
Traceback (most recent call last):
File "<MotionBuilder>", line 1, in <module>
NameError: name 's' is not defined

The names available in the editor and the Python global namespace are always the names defined in the last script executed plus all names defined after executing a script. This affects the Python object system and Auto completion.