BackTalk to Document The Zope Book (2.6 Edition)/Acquisition

[email protected]
Newsgroups gmane.comp.web.zope.zdp
Message-ID <[email protected]>
A comment to the paragraph below was recently added via http://zope.org/Documentation/Books/ZopeBook/2_6Edition/Acquisition.stx#2-1

---------------

    In a typical object-oriented language, there are rules to the way
    a *subclass* inherits behavior from its *superclasses*.  For
    example, in Python (a *multiple-inheritance* language), a class
    may have more than one superclass, and rules are used to determine
    which of a class' superclasses is used to define behavior in any
    given circumstance.  We'll define a few Python classes here to
    demonstrate.  You don't really need to know Python inside and out
    to understand these examples.  Just know that a 'class' statement
    defines a class and a 'def' statement inside of a class statement
    defines a method.  A class statement followed by one or more words
    inside (Parenthesis) causes that class to *inherit* behavior from
    the classes named in the parenthesis.::

      class SuperA:
          def amethod(self):
              print "I am the 'amethod' method of the SuperA class"

          def anothermethod(self):
              print "I am the 'anothermethod' method of the SuperA class"

      class SuperB:
          def amethod(self):
              print "I am the 'amethod' method of the SuperB class"

          def anothermethod(self):
              print "I am the 'anothermethod' method of the SuperB class"

          def athirdmethod(self):
              print "I am the 'anothermethod' method of the SuperB class"

      class Sub(SuperA, SuperB):
          def amethod(self):
              print "I am the 'amethod' method of the Sub class"

      % Anonymous User - Jan. 12, 2004 11:08 pm:
       In the SuperB class, athirdmethod() should probably print that it is the 'athirdmethod' method, rather than
       the 'anothermethod' method (which it isn't). It might confuse people who are new or (like me) sleepy.

_______________________________________________
ZDP maillist  -  [email protected]
http://mail.zope.org/mailman/listinfo/zdp
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.