Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.068 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'classes.': 0.07; 'python': 0.11; '23,': 0.16; 'definition.': 0.16; 'inheritance': 0.16; 'thought.': 0.16; 'wrote:': 0.16; 'flexibility': 0.18; 'say,': 0.18; 'runs': 0.18; 'class,': 0.22; 'enforce': 0.22; 'suppose': 0.22; '2015': 0.23; 'module': 0.23; 'sat,': 0.23; 'header:In- Reply-To:1': 0.24; 'written': 0.24; 'message-id:@mail.gmail.com': 0.28; "i'm": 0.29; 'hacker': 0.29; 'parent': 0.29; 'post': 0.32; 'though,': 0.32; 'class': 0.33; 'problem': 0.33; 'usually': 0.33; 'another': 0.34; 'received:google.com': 0.34; 'to:addr:python- list': 0.35; 'really': 0.35; 'but': 0.36; 'list,': 0.36; 'there': 0.36; "let's": 0.36; 'should': 0.37; 'subject:: ': 0.37; "won't": 0.38; 'names': 0.38; 'pm,': 0.39; 'method': 0.39; 'to:addr:python.org': 0.39; 'seem': 0.39; 'subject:-': 0.39; 'why': 0.40; 'some': 0.40; 'john': 0.61; 'design,': 0.61; 'within': 0.64; 'different': 0.64; 'between': 0.65; 'dr.': 0.69; 'behaviors': 0.72; 'unusual': 0.72; 'collision': 0.84; 'to:name:python': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=ZCxrxa5R9kBUnky3w2EYXckemKSHkak8KyaPYLJRgYI=; b=GhVBSNkJ4rd0QT2arWGkITehAHUPx4eXsIOebCOziROlvuaiwOmw1eqELRJJakJGUR pt10dCt0KAGnyhhUmlkl7xlXz3JPVGlQKPRQFORa5Ulru+P0w5lYugXXsMdcQ9W/6zC2 POeMr4CR32XnpeT8btFWLF2NZPJ5oC/Ck/MUP/PL8xJZbgAuEqp2PTwP/WpbcAd2FkOH 507iPLWO6eOjfl9opnFFgq/uACPJKr0XXFQJme0eM7vn/cPVXSSdOVfP+ycMJ8t70ysg wX3P5iaAO24NuLLQAfvUxMnkHfcRWphwncqxd0Xn72jJDK2qW+1rgqeg8sp+9nMCEhQE H1fQ== X-Received: by 10.43.65.19 with SMTP id xk19mr18757554icb.20.1432453222022; Sun, 24 May 2015 00:40:22 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: Ian Kelly Date: Sun, 24 May 2015 01:39:41 -0600 Subject: Re: mix-in classes To: Python Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1432453224 news.xs4all.nl 2880 [2001:888:2000:d::a6]:45947 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:91163 On Sat, May 23, 2015 at 7:53 PM, Dr. John Q. Hacker wrote: > 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.) Usually with mixins, one just wants to call a method of a specific mixin; a name collision is likely a symptom of poor design, and it would be unusual to want to call *all* mixin methods with the same name. If you really want to do that for a particular method though, is there some reason why super() won't suffice?