pelos Posted January 13, 2014 Share Posted January 13, 2014 i am trying to put a code into a button that will print the values of some parameters, i was able to make a list with t = [x for x in hou.pwd().parms() if x.name().startswith("blend")]; then i can print the list of the parameters that i want with print t; but if i want to do something to each one is when starts to break: t = [x for x in hou.pwd().parms() if x.name().startswith("blend")]; print t; for i in t: print i.eval(); the funny thing is if i print all directly with out doing the filter list does work =( for i in hou.pwd().parms(): print i.eval(); any cool tip that might work? thanks. Quote Link to comment Share on other sites More sharing options...
graham Posted January 13, 2014 Share Posted January 13, 2014 You should be able to do something like this: for i in (x for x in hou.pwd().parms() if x.name().startswith("blend")): print i.eval() It removes one of the loops, but you also have to do it as a generator expression, rather than a list comprehension, thus the () instead of the []. 1 Quote Link to comment Share on other sites More sharing options...
pelos Posted January 13, 2014 Author Share Posted January 13, 2014 thanks graham, cool trick =). do you know why for i in t" doesnt work in houdini? we tought that we could store the list in a variable t, and then use another loop. Quote Link to comment Share on other sites More sharing options...
graham Posted January 13, 2014 Share Posted January 13, 2014 Unfortunately I'm not too sure about the intricacies about Python and single line statements. It's also no a Houdini specific thing. If you take the giant line from up there that doesn't work in Houdini, it doesn't work in Python either. 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.