Jump to content
Sign in to follow this  
jonp

Accessing preloaded python modules in an expression

Recommended Posts

After a bit of light testing it seems that if I import a Python module when loading Houdini, using pythonrc.py, I cannot later use it directly in a parameter expression.   Instead I have to import it into the expression again, which could make the expression string more complicated and error-prone (multiple lines or semicolons).

Is this really the case?  I feel like I must not be doing something correctly.

Share this post


Link to post
Share on other sites

Probably shouldn't post anything over Christmas / NYE break...

Share this post


Link to post
Share on other sites

Additionally, to use random modules in one-liners, sometimes I like to use the __import__ function, like this:

__import__('re').sub('foo','bar','foobar')

Still makes your expression longer, but at least it's a single line.

 

-James

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×