How do I use getattr and setattr properly in Python? [closed]

The second argument to getattr and setattr are strings that name the attribute you want. That is, getattr(name, “expected_grade”). Using a variable as the second argument means that the value of the variable is used as the name. Generally, though, there is no real difference between name.expected_grade and getattr(name, ‘expected_grade’), although you can supply getattr … Read more