I'm a bit confused about using getattr()
with a string. I can do something like
list_ = []
getattr(list_, 'insert')(0,1)
And that will work as expected. When I try to do getattr(list_, 'sort')
or getattr(list_, 'pop')
then it does not work as expected and will not modify the list. Why do only some string methods work with getattr()
?