Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.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.093 X-Spam-Evidence: '*H*': 0.83; '*S*': 0.01; 'factory': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'sup': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'aug': 0.22; 'subject:problem': 0.24; 'class.': 0.26; 'this:': 0.26; 'header :In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'am,': 0.29; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'common': 0.35; 'except': 0.35; 'received:google.com': 0.35; 'instances': 0.36; 'to:addr:python-list': 0.38; 'itself': 0.39; 'to:addr:python.org': 0.39; 'decided': 0.64; 'itself?': 0.84; 'subject:Class': 0.91; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=xUWMcpMmh+mB0AbWrnzi3tOQtQ+RHiXQd0DPHO8osWw=; b=b2jlPZQ1bbM+tQkwrCvqrMgtKp46oaTMOWyxdDaZXWCeDOERVpHKCZ+bPVnjVdg6LO HzpBDBKUQLoVPU6VyhsPFjtWxyT6EIQ8mVA/Ya5AoVOJjDf7DBK+sM0HGy3xLVGAfMRP Gdj8bTOG3w9l5ZfFVJ2cIsbvcrsDkvqL6kxRAaaKC3SQO0nGgJ/sP3WpOXy1DoV4ikzR Vuw5VLsMWXWh+DeuiTQm1x1T5QfjPxC9/XTIkN6oly71Pu3j7uiSJcIuapTfzifjx3Qp EQHop9LbLxAXjXkHvS+S2TbU6a5qUSBNNGqmpNWRHdpUFxbevs7W+v/3xfW+Pk3Rlwzv 739A== MIME-Version: 1.0 X-Received: by 10.220.169.146 with SMTP id z18mr89792vcy.80.1375781439579; Tue, 06 Aug 2013 02:30:39 -0700 (PDT) In-Reply-To: References: Date: Tue, 6 Aug 2013 10:30:39 +0100 Subject: Re: Class hierarchy problem From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1375781442 news.xs4all.nl 15875 [2001:888:2000:d::a6]:37180 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:52014 On Tue, Aug 6, 2013 at 10:10 AM, BrJohan wrote: > Now, I want to create instances of the correct subclasstype as decided by > the common baseclass, like this: > > i = Sup(args_allowing_the_baseclass_to_deduce_correct_subclass) > > where i can be of any class except Sup itself (as decided by Sup) Can you do this as a factory function instead of the class itself? Then all you need to do is call the appropriate class. ChrisA