In Blender 2.91.2 I'm able to hide objects from the viewport by selecting them first and then using
mySelection = bpy.context.selected_objects
for obj in mySelection:
obj.hide_set(True)
However, doing the reverse, by selecting them on the outliner doesn't seem as trivial
I'm aware of this post, but still unable to formulate a solution.
I've tried using mySelection = bpy.context.collection
but it seems a collection is not iterable.