[Tutor] problem with a sub-class
s.shall at virginmedia.com
Fri Dec 1 06:30:14 EST 2017
On 30/11/2017 22:08, Alan Gauld via Tutor wrote:
> On 30/11/17 15:37, Shall, Sydney wrote:
>> My problem is with constructing a sub-class.
>> My sub-class is constructed as follows:
>> import Population_ProductivityV24 as POCWP
> Note that POCWP is an alias for the *module* Population_ProductivityV24.
> It is not a class.
>> line 27 : class SimulateCycleZero(POCWP):
> Here you define a class that subclasses your imported module.
> Frankly I'm surprised that you don't get an error there
> but hey...
>> line 28 : def __init__(self, dirname_p):
> But this is now an init for a subclass of module.
>> The error message is as follows:
>> line 27, in <module>
>> class SimulateCycleZero(POCWP):
>> TypeError: module.__init__() takes at most 2 arguments (3 given)
> So I'm guessing the use of a module to subclass
> has confused things and I confess I'm not clear on
> exactly what is going on and why you get this message.
> But I'm pretty sure you don;t want to subclass your
> imported module and thats the mistake.
Thanks to Alan and Peter for explaining sub-classing to me. I understand
a bit better now. My program is corrected and does not give the error
More information about the Tutor