I have a list of objects. Object has >10 attributes. I want to make a list containing only subsets of specific attributes from class.
Is there any built-in functions to do that? Or if not, what would be the most pythonic way to do this?
I tried this, but I would prefer to have a dynamic way to reference the specific attributes (e.g. pass a dictionary or a similar solution, that would enable me to figure out which attributes in runtime)
filtered_list = [[object.attr1, object.attr2] for object in list_objects]
(The solution can be just for Python 3)