Almost forgot (four day Easter weekend and all that) but Tim has changed
the ArgumentServer code now (in v2.2.2) so that
argServer.getCurrentPeaks() returns a copy of the list, so you won't need
to make a copy yourself any more.
Wayne
On Thu, 5 Apr 2012, Patrick van der Wel wrote:
> Thanks! That works a lot better.
>
> Patrick
>
>
> On Apr 5, 2012, at 11:09 AM, Wayne Boucher wrote:
>
>> Hello,
>>
>> This is happening because the deletePeak() function is looping over the peaks as it is deleting them. This causes a problem with the list returned by argServer.getCurrentPeaks() because other code is automatically modifying that list when a peak is deleted. Looping over a list that is being modified is a big no-no in Python. The work around here is to do:
>>
>> peaks = argServer.getCurrentPeaks()
>> peaks = peaks[:] # this makes a copy of the list
>> deletePeak(peaks)
>>
>> Wayne
>>
>> On Thu, 5 Apr 2012, Patrick van der Wel wrote:
>>
>>> Hi,
>>>
>>> I was trying to put together a simple macro in which some peaks get deleted. When I use the "deletePeak(peaks)" function, this kind of happens, except that it deletes all but one of the selected peaks. (Having prepopulated the peaks with the current peak selection).
>>>
>>> Is this a bug in that command? Is there some better code to do this?
>>>
>>> Patrick
>
|