Advertisement
Guest User

horizon defaults old

a guest
May 22nd, 2013
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. # a lot of code ommitted
  2. class FilterAction():
  3.     important_attribute = "I am important"
  4.    
  5.     def __init__(self, important_attribute=None):
  6.         self.important_attribute = important_attribute or getattr(self, "important_attribute")
  7.    
  8.  
  9. class MyGreatFilterAction(FilterAction):  
  10.     important_attribute = "I am not so important in this class"​​
  11.    
  12.     def print_important_attribute(self):
  13.         print self.important_attribute
  14.    
  15. m = MyGreatFilterAction()
  16. m.print_important_attribute()    
  17.  
  18. m = MyGreatFilterAction("I can be important for this object")
  19. m.print_important_attribute()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement