def iterate_my_objects_if_something(self):
    if self.my_objects is not None:
        for x in self.my_objects:
            if x.something:
                yield x
Python - Generator case where nothing to return