Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!bcyclone01.am1.xlned.com!bcyclone01.am1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'parameters': 0.04; 'represents': 0.05; 'modify': 0.07; 'wednesday,': 0.07; '*args,': 0.09; 'any)': 0.09; 'derived': 0.09; 'etc).': 0.09; 'lawrence': 0.09; 'subject:method': 0.09; 'thus,': 0.09; 'logic)': 0.16; 'subject:class': 0.16; 'substitution': 0.16; 'wrote:': 0.18; 'trying': 0.19; 'possible,': 0.19; 'example': 0.22; '(in': 0.22; 'header:User-Agent:1': 0.23; 'sort': 0.25; 'class.': 0.26; 'pass': 0.26; 'certain': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; '(like': 0.30; "i'm": 0.30; 'context.': 0.31; 'parameters.': 0.31; 'class': 0.32; 'call.': 0.33; 'implemented': 0.33; 'minimal': 0.33; "i'd": 0.34; 'subject:from': 0.34; 'basic': 0.35; 'but': 0.35; 'there': 0.35; '14,': 0.36; 'january': 0.37; 'list': 0.37; 'desirable': 0.38; 'generic': 0.38; 'jason': 0.38; 'same.': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'explain': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; "you're": 0.61; 'name': 0.63; 'burden': 0.68; 'received:74.208': 0.68; '2015': 0.84 Date: Wed, 14 Jan 2015 13:41:51 -0500 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Calling a derived class's constructor from a parent method References: <0fbb81a4-b37a-4428-9877-1637c5473f7f@googlegroups.com> In-Reply-To: <0fbb81a4-b37a-4428-9877-1637c5473f7f@googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V02:K0:s2Kxc6wpnnUJjmU9rHF1mX20gseZy9ge7Q9OGaXzGye 8wXoJTxDxmRYYSUrdQx9FDwPYv8TwDToZZ1wHLLgLJHXvRPi5F YTHokLbslww5z5RG5cyCTYozy92d4u6P2jNPnbzq8nlYajRoQo hlsjZymvk7f3Ww74gbdNq+e9eOBOiqqQmKKvtFVY7noYKhKJh4 H3MdT8QXtFmuoE1bRNRUChiMGfaS27HENIYyMtdx7KFdEDX0KK 9C8R/aVJt+YbBseJQkJSfvQS58tQkrSRPhnz9q+QTRhs+tiYQZ BTOeBUXlCAOea+hJypLRay8gATt4mJE9vqvZem6Udmx7vYxqCV MERv4LGJFDDV0eSYl4E0= X-UI-Out-Filterresults: notjunk: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: 22 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421260918 news.xs4all.nl 2851 [2001:888:2000:d::a6]:37957 X-Complaints-To: abuse@xs4all.nl X-Received-Bytes: 4476 X-Received-Body-CRC: 4229197466 Xref: csiph.com comp.lang.python:83777 On 01/14/2015 01:10 PM, jason wrote: > On Wednesday, January 14, 2015 at 12:05:55 PM UTC-5, Mark Lawrence wrote: > >> I'm confused, can you please explain what you're trying to achieve >> rather than how you're trying to achieve it and I'm sure that others >> will give better answers than I can :) >> > > Good call. Coming up with a minimal example make things pretty far out of context. > > The base class represents a generic function (in formal logic) with some name and a list of parameters. The derived class is some sort of specialization of that generic class (like associative functions, etc). > > It is desirable to do certain things to these functions, like perform substitution or canonization, that can be implemented in the basic class but which I'd like to return as a copy rather than modify the class. Thus, the base class needs to know which derived class (if any) to create. > > The burden is indeed on me to keep the signature of the init() for each of these the same. > If there are additional parameters possible, you might be able to use *args, **vargs to pass them through the call. -- DaveA