socek

Untitled

Jan 12th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. class ListMixin(object):
  2.  
  3.     def list(self):
  4.         return self.get_query()
  5.  
  6. class ReciveMixin(object):
  7.  
  8.     def receive(self):
  9.         return selg.get_query()
  10.  
  11.  
  12. class MyClass(ListMixin, ReciveMixin):
  13.  
  14.     def get_query(self):
  15.         return 1
  16.  
  17.     def get_second_query(self):
  18.         return 2
  19.  
  20. # to co chcesz, to aby ListMixin korzystało z .get_second_query, a ReciveMixin korzystało z self.get_query()
  21. # odpowiedź: nie da się tego zrobić "dziedziczeniem". Musisz nadpiać metodę .list()
Advertisement
Add Comment
Please, Sign In to add comment