Filter in iterators

Hi,

I often have this pattern in Python:

for vertex in mygraph.vertices():
    if not mygraph.vp.is_foo[vertex]:
        continue
    do_stuff_that_uses_all_vertices()

`is_foo` is a boolean property.

I know that there a vertex filters and GraphViews but in the loop body I
need access to all vertices. Only the iterator should be filtered.

Is there a way to specify a vertex filter only in the vertices iterator?
Something like:

for vertex in mygraph.vertices(vfilt=mygraph.vp.is_foo):
    do_stuff_that_uses_all_vertices()

Of course, this would be nice in all iterators (edges(), out_edges(),
...) ;).

Best,
Gerion

Hi,

What you want is achieved by the Python built-in filter() function:

   https://docs.python.org/3.8/library/functions.html#filter

Best,
Tiago