Is there an alternative to map() that doesn't return anything?

With the way that map() is designed it seems like it is intended to be used specifically when you are trying to return a list of modified things. I am wondering, is there an alternative to map() that is designed specifically for when you do not want to return whatever is being modified? I am currently working in a django project where I would like to set the initial value of a few fields if the instance already has data for these fields. Here is an example (note: I excluded some code not relevant to the discussion to keep it cleaner):

class EquipmentStatusForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.init_field(["fk_user"])

    def init_field(self, attr):
        if hasattr(self.instance, attr):
            if getattr(self.instance, attr) != "" and getattr(self.instance, attr) is not None:
                self.initial[attr] = getattr(self.instance, attr)

Say I wanted to extend this to use a list of attrs rather than a single one, and then set the initial value of all of these. I don't need the results to be returned because I am not actively doing anything with these attrs after I modify them. Is there a built in alternative to map() designed for this? Or am I really just stuck using a for loop?

Back to Top