Yes, it's called "eval"

http://docs.python.org/2/library/functions.html#eval

for example:
"""
>>> eval( "1 + 2" )
3
"""

There's also "exec":

"""
>>> exec ("print \"hello\"")
hello
"""

These functions are powerful enough that you can provide custom global and 
local variables via dictionaries.  In other-words: you can provide custom 
objects to your users for them to script/expression with.

-brad


On May 21, 2013, at 4:54 AM, Todd Widup <[email protected]> wrote:

> is there a python equivalent to eval?  
>  
> I am setting up a few things that could allow the user to specify a pre-build 
> function but user A could specify a different prebuild function than user B, 
> and I need some way of handling this.
>  
> only thing I can think of right now is using maya.mel.eval("python string")
> which I really don't like the idea of doing that.
>  
> any other ideas?
> 
> 
> -- 
> Todd Widup
> Creature TD / Technical Artist
> [email protected]
> [email protected]
> www.toddwidup.com
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to