Jump to content

Accessing preloaded python modules in an expression


jonp

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.

Link to comment
Share on other sites

  • 2 weeks later...

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...