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


Groups > comp.lang.python > #83777

Re: Calling a derived class's constructor from a parent method

Date 2015-01-14 13:41 -0500
From Dave Angel <davea@davea.name>
Subject Re: Calling a derived class's constructor from a parent method
References <cb109c66-090a-4779-b00e-43d964ae7252@googlegroups.com> <mailman.17729.1421255143.18130.python-list@python.org> <0fbb81a4-b37a-4428-9877-1637c5473f7f@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.17733.1421260917.18130.python-list@python.org> (permalink)

Show all headers | View raw


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

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


Thread

Calling a derived class's constructor from a parent method jason <jasonsewall@gmail.com> - 2015-01-14 08:45 -0800
  Re: Calling a derived class's constructor from a parent method Ian Kelly <ian.g.kelly@gmail.com> - 2015-01-14 10:00 -0700
  Re: Calling a derived class's constructor from a parent method Chris Angelico <rosuav@gmail.com> - 2015-01-15 03:56 +1100
  Re: Calling a derived class's constructor from a parent method Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-14 17:05 +0000
    Re: Calling a derived class's constructor from a parent method jason <jasonsewall@gmail.com> - 2015-01-14 10:10 -0800
      Re: Calling a derived class's constructor from a parent method Dave Angel <davea@davea.name> - 2015-01-14 13:41 -0500
    Re: Calling a derived class's constructor from a parent method alister <alister.nospam.ware@ntlworld.com> - 2015-01-14 18:18 +0000
  Re: Calling a derived class's constructor from a parent method Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-01-15 11:40 +1100
    Re: Calling a derived class's constructor from a parent method Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-01-15 04:44 +0000

csiph-web