Advertisement
Guest User

Untitled

a guest
Jun 1st, 2016
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. my_str = "Hello World"
  2. func1 = getattr(__builtins__, 'len')
  3. func1
  4. <built-in function len>
  5. func1()
  6. Traceback (most recent call last):
  7.   File "<stdin>", line 1, in <module>
  8. TypeError: len() takes exactly one argument (0 given)
  9.  
  10. func1(my_str)
  11. 11
  12.  
  13. func2 = getattr(my_str, 'replace')
  14. func2
  15. <built-in method replace of str object at 0x102d83cc0>
  16.  
  17. func2()
  18. Traceback (most recent call last):
  19.    File "<stdin>", line 1, in <module>
  20. TypeError: replace() takes at least 2 arguments (0 given)
  21.  
  22. func2("Hello", "Yello")
  23. 'Yello World'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement