Check out a post here: http://groups.google.com/group/python_inside_maya/browse_thread/thread/5ada870a705dfecf/fdf976179cf2a0c9?lnk=gst&q=__file__#fdf976179cf2a0c9
...for different ways to find out where a module lives. - Paul On Sep 24, 5:48 pm, [email protected] wrote: > Could __path__ also be queried to obtain that info, in this case? > > On Sep 24, 2009 5:02pm, Chris G <[email protected]> wrote: > > > Non-builtin modules should have a __file__ attr: > > os.path.dirname(spam.__file__) > > -Chris > > On Thu, Sep 24, 2009 at 7:24 PM, AK Eric [email protected]> wrote: > > > > In Python external to Maya, I'm used to doing this in a module, which > > > is a really convenient way to know the location the module is being > > > executed in. For a module living here: > > > > #---------- > > > # c:/temp/spam.py > > > import os > > > import sys > > > > print "Module Save Location:", os.path.dirname(os.path.abspath(sys.argv > > > [0])) > > > #---------- > > > > Would print if executed outside of Maya-Python: > > > c:/temp > > > > Makes it easy to find relative data. > > > But when I do this in Maya, no matter what, sys.argv[0] is always: > > > > C:\Program Files\Autodesk\Maya2010\bin\maya.exe > > > > Any module I put that code in returns back the Maya executable dir. > > > Driving me nuts! :) Anyone know a way around this? > > > > thanks > > --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/python_inside_maya -~----------~----~----~----~------~----~------~--~---
