Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91155

mix-in classes

Date 2015-05-23 20:53 -0500
Subject mix-in classes
From "Dr. John Q. Hacker" <zondervanz@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.1.1432432413.5151.python-list@python.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

The post on "different types of inheritence..." brought up a thought.

Let's say, I'm adding flexibility to a module by letting users change class
behaviors by adding different mix-in classes.

What should happen when there's a name collision on method names between
mix-ins?  Since they're mix-ins, it's not presumed that there is any parent
class to decide.  The proper thing would seem to call each method in the
order that they are written within the parent class definition.

I suppose one can create a method in the parent class, that runs the mixin
methods in the same order as in the inheritance list, but would there be a
better way for Python to enforce such a practice so as not to create class
anarchy?  (A problem for another topic.)

zipher

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

mix-in classes "Dr. John Q. Hacker" <zondervanz@gmail.com> - 2015-05-23 20:53 -0500
  Re: mix-in classes Steven D'Aprano <steve@pearwood.info> - 2015-05-24 21:11 +1000
    Re: mix-in classes Michael Torrie <torriem@gmail.com> - 2015-06-16 22:39 -0600

csiph-web