Can you give a more clear example of what you are wanting to do? You
say external are you trying to print attributes from other modules? If
so you need to import those modules and prefix the attributes with
that modules name.
# This works
a = 1
b = 2
scpt = 'print a, b'
exec( scpt, globals() )
# This works
a = 3
b = 4
def foo():
scpt = 'print a, b'
exec( scpt, globals() )
foo()
# This works
sys.path.append('C:/Documents and Settings/rtrowbridge/My Documents/
maya/2008/scripts')
"""
# script file looks like this
a = 5
b = 6
"""
scpt = 'import scriptfile; print scriptfile.a, scriptfile.b'
exec( scpt, globals() )
Hope that helps,
RyanT
Technical Artist
www.rtrowbridge.com/blog
NaughtyDog Inc.
On Mar 31, 5:35 am, King <[email protected]> wrote:
> Hi,
>
> I am trying to execute a small script, which actually is value of a
> string attribute:
>
> For example:
>
> a = 2
> b = 2
> scpt = node.myScript.get()
>
> Consider the value of "myScript" is "print a, b". I tried using this
> way because script uses variables that are
> not defined inside of it:
>
> python( scpt, globals() ) #Doesn't work.
> exec( scpt, globals() ) #Doesn't work.
>
> In case if script is not having dependency of any other external
> variables, then
> "python ( scpt )" works fine
>
> Cheers
>
> Prashant
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---