Hi Paul, Sorry I never replied back, thanks for the help!
I'm currently iterating over the list and creating a new one as I go based on what's found, then reassigning. I agree, the cast to a list is a good compromise. To offer an opinion to how it could be done, I'm not sure either, I'm indifferent. Considering a string as a list it works in a similar fashion, not allowing character item assignment... Justin On Tue, Jun 22, 2010 at 6:51 PM, Paul Molodowitch <[email protected]>wrote: > First off: if you just want to be able to find a way to do what you > want, you can cast the OptionVarList to a list, then re-assign the > list directly to the optionVar: > > varVal = list(pm.optionVar['CustomFileDialogSidebarUrls']) > varVal[0] = 'test' > pm.optionVar['CustomFileDialogSidebarUrls'] = varVal > > Now, for an explanation of OptionVarList's limited functionality: > first of all, it's limited because the underlying optionVar > implementation only makes certain things easy to do. optionVar has > int/float/stringValueAppend flags, so it's easy to implement append > for OptionVarList. It also has a 'removeFromArray' flag, so > technically that would be easy to add as well, but in order to make it > behave like a fully-modifiable iterable (with item assignment, > slicing, etc) would take more work. Which raises a second issue: do > we WANT the result returned for optionVar arrays to be easily > modifiable? Ie, if we return an object that behaves like a list, and > then do: > > myVars = pm.optionVar['myArrayOptionVar'] > > ...it might be very easy to forget that myVars is not a 'normal' list, > and that modifying it will actually modify the underlying optionVar. > In my opinion, since it's pretty easy to cast to a list, and then > assign that list directly to the optionVar, this seems like the best > compromise between easy modifcation and 'protection' from accidental > modifcation. > > Of course, what we have right now is a sort of hybrid approach, since > it does allow modification, but only in one specific way (ie, > appending). Dunno... I have mixed feelings on what 'should' be done > for this one... > > - Paul > > > > > > On Wed, Jun 16, 2010 at 12:11 PM, Justin Rosen <[email protected]> > wrote: > > I'm having a bit of trouble handling an optionVarList within the > > optionVarDict > > > > The new file dialog has a bookmark section and it's defined in the > optionVar > > CustomFileDialogSidebarUrls > > > > for bookmark in pm.optionVar['CustomFileDialogSidebarUrls']: > > > > print bookmark > > > > The bookmarks I want to add are shot specific so I need to delete/modify > > bookmarks based on my environment. Is this possible to do (The > delete/modify > > part)? > > > > pm.optionVar['CustomFileDialogSidebarUrls'] is an OptionVarList which > seems > > to have very limited functionality. I can append, but I can't remove, or > > modify? > > > > Maybe I'm missing something? > > > > for index in xrange(len(pm.optionVar['CustomFileDialogSidebarUrls'])): > > > > print pm.optionVar['CustomFileDialogSidebarUrls'][index] > > > > pm.optionVar['CustomFileDialogSidebarUrls'][index] = 'test' > > > > # Error: TypeError: 'OptionVarList' object does not support item > assignment > > # > > > > Thanks! > > > > -- > > http://groups.google.com/group/python_inside_maya > > -- > http://groups.google.com/group/python_inside_maya > -- http://groups.google.com/group/python_inside_maya
