= The hou.session module = The interactive Python shell is a great way to test and experiment with snippets of scripts. When you want to run the same sequence of statements multiple times, though, it's tedious to enter those statements into the shell, especially if you need to iteratively modify a function definition. Instead of writing code in the interactive shell, a nicer solution is use an editor to write a Python function and call that function from the shell. Houdini uses a special module named hou.session to store Python code that's saved with the hip file. You can write functions in this module and access them from anywhere in Houdini. Choose __Windows > Python Source Editor__ to edit the contents of the hou.session module. For example, suppose you want to change all the parameter values starting with `"/home/bob"` to start with `"$HIP"`. You can write some functions in the hou.session module and then modify and tweak them. {{{ #!python def fixFilePrefixes(node, from_prefix, to_prefix, node=None): """For a node and all its children and grandchildren, change all non-animated file name parameters starting with `from_prefix` so they instead start with `to_prefix`. If the node is not specified, the root node (/) will be used.""" if node is None: node = hou.node('/') for parm in node.parms(): template = parm.parmTemplate() if (template.type() == hou.parmTemplateType.String and template.stringType() == hou.stringParmType.FileReference and len(parm.keyframes()) == 0 and parm.unexpandedString().startswith(from_prefix)): print "Fixing:", parm.path() parm.set(to_prefix + parm.unexpandedString()[len(from_prefix):]) for child in node.children(): fixFilePrefix(from_prefix, to_prefix, child) }}} Then, from the Python shell you would write: {{{ #!pycon >>> hou.session.fixFilePrefixes("/home/bob", "$HIP") Fixing: /obj/geo1/file1/file }}} Don't forget that the contents of hou.session change depending on which hip file is loaded. Don't use hou.session for functions that need to be available for all sessions or that are for use by a digital asset. See below for other ways to create functions and classes.