old_contents: __author__ = 'sergey'
  
  
  class AbstractDuck:
  
      def __init__(self, name):
          self.name = name
  
      def setFly(self, method):
          self.fly = method
  
      def setQuack(self, method):
          self.quack = method
  
      def swim(self):
          print "All ducks float!"
  
  
  class Flying:
      # def __call__(self, *args, **kwargs):
      #     print args
      #     print "I'm fly"
  
      def fly(self):
          print "I'm fly-method"
  
  
  class Quacking:
      def __call__(self, *args, **kwargs):
          print "quack-quack"
  
  
  class DuckRedCrestedPochard(AbstractDuck):
      def __init__(self, name):
          AbstractDuck.__init__(self, name)
          fly_instance = Flying()
          self.setFly(fly_instance)
      # def swim(self):
      #     Swiming()
  
  
  class SantaCruz(AbstractDuck):
      def __init__(self, name):
          AbstractDuck.__init__(self, name)
          fly_instance = Flying()
          self.setFly(fly_instance.fly())
          quack_instance = Quacking()
          self.setQuack(quack_instance)
  
  
      # def swim(self):
      #     Swim.swim()
  
  
  if __name__ == '__main__':
      # FredyDuck = DuckRedCrestedPochard('FredyDuck')
      # FredyDuck.swim()
      # #FredyDuck.fly()
  
      AlphaDuck = SantaCruz('AlphaDuck')
      AlphaDuck.swim()
      AlphaDuck.fly()
  
  
new_contents: __author__ = 'sergey'
  
  
  class AbstractDuck:
      def __init__(self, name):
          self.name = name
          print "I'm " + name
  
      def setFly(self, method):
          self.fly = method
  
      def setQuack(self, method):
          self.quack = method
  
      def swim(self):
          print "\tAll ducks float!"
  
  
  # to call a method through the "fly" of the object
  class Flying:
      # def __call__(self, *args, **kwargs):
      #     print "I'm fly"
  
      def fly(self):
          print "\tI'm fly-method"
  
  
  # to call a method through the object
  class Quacking:
      def __call__(self, *args, **kwargs):
          print "\t... quack-quack ..."
  
  
  class DuckRedCrestedPochard(AbstractDuck):
      def __init__(self, name):
          AbstractDuck.__init__(self, name)
  
          fly_instance = Flying()
          self.setFly(fly_instance.fly)
  
          quack_instance = Quacking()
          self.setQuack(quack_instance)
  
  
  class SantaCruz(AbstractDuck):
      def __init__(self, name):
          #print "I'm " + name
          AbstractDuck.__init__(self, name)
  
          fly_instance = Flying()
          self.setFly(fly_instance.fly)
  
          quack_instance = Quacking()
          self.setQuack(quack_instance)
  
  
  class WoodDuck(AbstractDuck):
      def __init__(self, name):
          #print "I'm " + name
          AbstractDuck.__init__(self, name)
  
  
  class DuckDecoy(AbstractDuck):
      def __init__(self, name):
          AbstractDuck.__init__(self, name)
  
          quack_instance = Quacking()
          self.setQuack(quack_instance)
  
  
  if __name__ == '__main__':
      AlphaDuck = SantaCruz('AlphaDuck')
      AlphaDuck.swim()
      AlphaDuck.fly()
      AlphaDuck.quack()
  
      BetaDuck = DuckRedCrestedPochard('BetaDuck')
      BetaDuck.swim()
      BetaDuck.fly()
      BetaDuck.quack()
  
      GammaDuck = WoodDuck('GammaDuck')
      #GammaDuck.quack()
      #GammaDuck.fly()
      Manok = DuckDecoy('DuckManok')
      Manok.quack()
  
subject: comment #1