Advertisement
oquidave

python classes

Mar 8th, 2013
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1.  
  2. In [91]: class myclass:
  3.    ....:     def __init__(self):
  4.    ....:         self.f_name = "david"
  5.    ....:     def f_name(self, first_name):
  6.    ....:         self.f_name = first_name
  7.    ....:         print "Your first name is: ", self.f_name
  8.    ....:        
  9.  
  10. In [92]: bio = myclass
  11.  
  12. In [93]: bio.f_name("frank")
  13. ---------------------------------------------------------------------------
  14. TypeError                                 Traceback (most recent call last)
  15. /home/oquidave/Documents/<ipython-input-93-d68dda092f63> in <module>()
  16. ----> 1 bio.f_name("frank")
  17.  
  18. TypeError: unbound method f_name() must be called with myclass instance as first argument (got str instance instead)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement