Thanks.
The import statement no longer throws an error, but the reload
statement does:
def reloadScript():
# Query textScrollList for selected script:
selectedScript = cmds.textScrollList('scriptList', q=1, si=1)[0] #
Items returned as a list
print selectedScript #This works and prints the name of the
hilighted script in the textScrollBox
import sys
name = selectedScript
__import__(name)
reload (name)
# TypeError: reload() argument must be module #
Hopefully I'm close...
On Feb 9, 11:01 pm, Chris Gardner <[email protected]> wrote:
> __import__ will let you import from a module by passing it a string
>
> http://docs.python.org/library/functions.html#__import__
>
> eg
>
> >>> import sys
> >>> name = 'foo.bar.baz'
> >>> __import__(name)
>
> cheers,
> chrisg
>
> On 10 February 2011 15:54, PixelMuncher <[email protected]> wrote:
>
> > I've setup a simple UI w/a textScrollBox so I can keep a list of my
> > scripts and reload any of them by clicking. But the 'import' and
> > 'reload' statements don't like that idea - they need a module.
> > Can anyone help?
> > def reloadScript():
> > # Query textScrollList for selected script:
> > selectedScript = cmds.textScrollList('scriptList', q=1, si=1)[0] #
> > Items returned as a list
> > print selectedScript #This works and prints the name of the
> > hilighted script in the textScrollBox
>
> > import selectedScript
> > # ImportError: No module named selectedScript #
> > reload (selectedScript)
> > # TypeError: reload() argument must be module #
>
> > --
> >http://groups.google.com/group/python_inside_maya
>
>
--
http://groups.google.com/group/python_inside_maya