Advertisement
Ruddog

Calling Class rather calling method

May 18th, 2017
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. class userInfo:
  2. def user_data(self,name,age,phone):
  3. self.name=name
  4. self.age=age
  5. self.phone=phone
  6. return (self.name + ' ' + self.age + ' ' + phone)
  7.  
  8. userfile=userInfo() #This is easier to follow but not sure how it affects your model,IMHO.
  9.  
  10. print(userfile.user_data('Terry', '54', '999-222-3333'))
  11. print(userfile.user_data('Wanda', '54', '999-222-3333'))
  12. print(userfile.user_data('Gene', '54', '999-222-3333'))
  13.  
  14. """Found this extremely easy to follow;
  15. When you go to print you call the Class name dot method name with pass values.
  16.  
  17. format makes a lot of sense....
  18.  
  19. class.method(value,value,etc) #Visualizing this is simpler for me.
  20.  
  21. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement