Can someone please explain why we would use setattr(x, 'foobar', 123) instead of x.foobar = 123

What is the purpose of the setattr() function and how does it add value?

Thanks

```

Can someone please explain why we would use setattr(x, 'foobar', 123) instead of x.foobar = 123

What is the purpose of the setattr() function and how does it add value?

Thanks

```

We cannot write `x.y = z`

if `y`

is not a defined attribute.

We can write, `setattr(x, y, z)`

at any time, though. `y`

is now dynamic.