[lang-ref] ( run_method_by_name_string ) ( python )
def test_run_method_by_name_string():
# getattr(instance, methodname)
s = 'ABC'
f = getattr(s, 'lower')
r = f()
assert r == 'abc'
f = getattr(s, 'replace')
r = f('B', 'b')
assert r == 'AbC'
with pytest.raises(AttributeError):
getattr(s, 'no_such_method')