Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- my_str = "Hello World"
- func1 = getattr(__builtins__, 'len')
- func1
- <built-in function len>
- func1()
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: len() takes exactly one argument (0 given)
- func1(my_str)
- 11
- func2 = getattr(my_str, 'replace')
- func2
- <built-in method replace of str object at 0x102d83cc0>
- func2()
- Traceback (most recent call last):
- File "<stdin>", line 1, in <module>
- TypeError: replace() takes at least 2 arguments (0 given)
- func2("Hello", "Yello")
- 'Yello World'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement