peliosis Posted July 19, 2011 Share Posted July 19, 2011 Is it correct that if I run hou.setSessionModuleSource('a = 1') hou.setSessionModuleSource('b = 1') "a" should be deleted. The source editor window shows only b = 1, but in hou.session both variables are kept??? dir(hou.session) gives a AND b, so the first variable is not deleted? It's not the matter of life and death but supposed "a" can possibly be a huuuge array it can clutter memory. Quote Link to comment Share on other sites More sharing options...
graham Posted July 19, 2011 Share Posted July 19, 2011 (edited) This is what I would expect to happen given how Python modules tend to work. The session module is just another module and the source is what defines it. Every time you change something through either the dialog or by setting it using Python, you are essentially reloading that module, which creates any new data members and refreshes any that are changed. Ones that were removed or renamed will still exist until the session is over or they are specifically deleted. This is a regular Python behavior, not specific to Houdini. An example is as follows: Define a new module, mymodule.py that contains a definition for a function, foo() and a constant x=5. If you import that module into a standard Python session you then can access foo and x. Now, in that file, delete the definitions for the function and constant and define a new function, bar() and a constant y=-1. If you reload(mymodule) in your session and do a dir(mymodule) you will now see foo, bar, x and y even though you removed the original function and constant in the source. To remove the 'leftover' members you could do del(mymodule.foo) and del(mymodule.x). If you start a new session and import mymodule you will only get bar and y. Edited July 19, 2011 by graham Quote Link to comment Share on other sites More sharing options...
peliosis Posted July 19, 2011 Author Share Posted July 19, 2011 Thanks a lot Graham! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.