[Tutor] problem with a sub-class

Alan Gauld alan.gauld at yahoo.co.uk
Thu Nov 30 17:08:30 EST 2017

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:
>    File 
> "/Users/sydney/AnacondaProjects/Capital/Capital_with_productivity/Current_Versions/Simulate_Cycle_Zero_V3.py", 
> 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.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

More information about the Tutor mailing list