I think your issue might be using this function to write to the parameter.
Try using setattr instead as in Phil's post here: