# iterate through clips; No Error message for non existing sources on Mac

**URL:** https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535
**Category:** ParaView Support
**Created:** [June 8, 2020, 8:29am UTC](https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535 "2020-06-08T08:29:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 8, 2020, 8:29am UTC](https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535/1 "2020-06-08T08:29:59Z")

</div>

Hey everybody,

I’d like to do some operations on all clips in my states. Their number varies between the different states.  
On Windows I address the Clips like this:

```
i = 1
while 1:
    clipNEW = FindSource("Clip"+str(i))
    if clipNEW is None:
        break
    i += 1

```

Unfortunately on Mac this doesn’t work because you don’t get an error message when trying to find a Source that doesn’t exist. Instead nothing happens.

How could I do this elsewise?

---

<div class="post-metadata">

### Author: ![lhofmann](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@lhofmann](https://discourse.paraview.org/u/lhofmann)
#### Post date: [June 8, 2020, 8:59am UTC](https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535/2 "2020-06-08T08:59:33Z")

</div>

You can get a dict of all sources using `GetSources()`. To get a list of all Clip filters:

```python
[s for s in GetSources().values() if s.GetXMLName() == 'Clip']

```

---

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 9, 2020, 4:53pm UTC](https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535/3 "2020-06-09T16:53:32Z")

</div>

How would I do this in case of IntegrateVariables Filters?  
replacing ‘Clip’ by ‘IntegrateVariables’ didn’t work

---

<div class="post-metadata">

### Author: ![lhofmann](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/l/9e8a1a/32.png) [@lhofmann](https://discourse.paraview.org/u/lhofmann)
#### Post date: [June 11, 2020, 11:14am UTC](https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535/4 "2020-06-11T11:14:16Z")

</div>

The “Integrate Variables” filters have `IntegrateAttributes` as name. It is probably easier to use the label (which are displayed in the paraview GUI) instead:

```python
[s for s in GetSources().values() if s.GetXMLLabel() == 'Integrate Variables']

```

---

<div class="post-metadata">

### Author: ![Resa](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/r/94ad74/32.png) [@Resa](https://discourse.paraview.org/u/Resa)
#### Post date: [June 13, 2020, 7:20am UTC](https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535/5 "2020-06-13T07:20:34Z")

</div>

Thank you @lhofmann  
Now I have one last problem:  
If I use

> [@lhofmann](#):
>
> ` for s in GetSources().values() if s.GetXMLLabel() == 'Integrate Variables']`

the order of the filters seems random. What I would need is all values in exactly that order how they are displayed in the Pipeline. How can I achieve that?

---

<div class="post-metadata">

### Author: ![waveman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/e95f7d/32.png) [@waveman](https://discourse.paraview.org/u/waveman)
#### Post date: [December 21, 2021, 5:38pm UTC](https://discourse.paraview.org/t/iterate-through-clips-no-error-message-for-non-existing-sources-on-mac/4535/6 "2021-12-21T17:38:20Z")

</div>

If you consistently use .sort() at all steps, it should work. For example:

`[s for s in GetSources().values if s.GetXMLLabel() == 'Integrate Variables'].sort()`

This will sort in place.
