This pretty much goes against one of the main paradigms of Python, that each module has its own namespace with its own set of 'names' (variable, function, and class definitions). It takes care of hard-to-trace bugs that result from global variables being modified unexpectedly by various scripts... If you really wanted to do this, you could 'shove' those modules into a particular module like so:
in userSetup.py import maya.cmds as MPyCmds import someOtherScript someOtherScript.MPyCmds = MPyCmds # from this point, functions that run inside of someOtherScript will have access to a 'MPyCmds' module It's a hack, and it's probably not how you'd want it to work... It might make more sense to have one module, call it studioModule.py, that would import all sorts of different modules, declare useful functions and global variables, and then other scripts would just import that one. So you'll have a central location to change how other scripts work: in studioModule.py: import maya.cmds as MPyCmds import MySQLdb as db kStudioRoot = "z:" kStudioModels = kStudioRoot + "/asset/models" # etc... On Tue, Sep 23, 2008 at 11:40 AM, djTomServo <[EMAIL PROTECTED]> wrote: > > Greets all, I've been researching this topic for the last few days and > I think the answer is something along the lines of "it's not > possible", but maybe someone has some insight on this I don't. > > So basically we're setting up our Maya/Python development environment > at the studio here and we'd like to be able to import a bunch of > modules/scripts in userSetup.py then be able to access all that from > external scripts without having to do an explicit import in the > script, similar to how you do global variables/sourcing in MEL. I'm > sure this has been asked before, and i did take a look at the > pythonScripts.py file that comes with the devkit, is it possible to do > something similar to what's presented there to get this sort of thing > working? So to recap with an example: > > in userSetup.py > > import maya.cmds as MPyCmds > > in someOtherScript.py > > access MPyCmds without having to re-import. > > Not a critical thing, just curious as to if it's do-able. Thanks all! > > > -- - Ofer www.mrbroken.com --~--~---------~--~----~------------~-------~--~----~ Yours, Maya-Python Club Team. -~----------~----~----~----~------~----~------~--~---
