I know this is not good coding and I'm looking to improve it. I want to get the first name by default if no name is supplied. My hack still enters the for loop and if it would be a big one it would be innefficient. But if I do all the attributions that I'm doing in the for loop's inside if, again, in the outside if, I would duplicate code. And I wouldn't use a function just to set attributes so I'm not sure how to proceed here.
if not name:
name = self.data['big_list'][0]['name']
for i in range(len(self.data['big_list'])):
if self.data['big_list'][i]['name'] == name:
self.name = name
self.address = self.data['big_list'][i]['address']
...
return
for i in self.data['big_list']: