Inheritance confusion

Hook Hook at
Sat Apr 19 08:37:33 CEST 2008


I'm having a problem with multiple inheritance - it's clearly something 
I've missed, but the web pages and books that I've consulted aren't 
helping, so I'll throw myself on the mercy and collective wisdom of 

I've got 4 files (what I'll show has the active content removed for 
class Errors (object) :
    def __init__ (self, params) :

    def Error (self, string) :
        return 100
class DT (object) :
    def __init__ (self, params) :

    def Date (self, epoch, pattern = 'd mmm yyyy') :
        dt = datetime.datetime.fromtimestamp (epoch)
from DT_m import DT
from Error_m import Errors

class Hook (Errors, DT) :
    def __init__ (self, params) :
        DT.__init__ (self, params)
        Errors.__init__ (self, params)
from Hook_m import Hook

class DB (Hook) :
    def __init__ (self, params) :
        Hook.__init__ (self, params)

And a test script:


import os
import re
import string
import sys

from DB_m import DB

Dict = dict ()
Dict ['logdir'] = '/tmp/log'
Dict ['diag']   = 1

Obj = DB (Dict)
print dir (Obj)
Obj.Connect ('Database')

When I run the script I get this:

Traceback (most recent call last):
  File "./", line 20, in <module>
    Obj.Connect ('Database')
  File "/mnt/isis/Projects/Python/Learning/", line 102, in Connect
    self.TRACE ("DB::Connect (" + database + "," + mode)
  File "/mnt/isis/Projects/Python/Learning/", line 314, in TRACE
    self.DailyLog (msg)
  File "/mnt/isis/Projects/Python/Learning/", line 98, in 
    dt          = self.Date (time ())
TypeError: 'module' object is not callable

Googling the "TypeError" message suggests that I've got a module and 
class with the same name, but I can't see that I have.

Can someone point me in the right direction please?

If you need to see all the source, can do, but it's certainly too much 
for an intro message!



More information about the Python-list mailing list