Update parts of a trainer in a database

def update_trainer(self, trainer, username=None, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=None, daily_goal=None, total_goal=None, prefered=None):
		"""Update parts of a trainer in a database"""
		args = locals()
		if not isinstance(trainer, Trainer):
			raise ValueError
		url = api_url+'trainers/'+str(trainer.id)+'/'
		payload = {
			'last_modified': maya.now().iso8601()
		}
		
		for i in args:
			if args[i] is not None and i not in ['self', 'trainer', 'start_date']:
				payload[i] = args[i]
			elif args[i] is not None and i=='start_date':
				payload[i] = args[i].date().isoformat()
		
		r = requests.patch(url, data=json.dumps(payload), headers=self.headers)
		print(request_status(r))
		r.raise_for_status()
		return Trainer(r.json())