Inheritance confusion

2008-04-18 Thread Hook
Hi,

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 
Usenet!

I've got 4 files (what I'll show has the active content removed for 
brevity):

Errors_m.py
~~~
class Errors (object) :
def __init__ (self, params) :
pass

def Error (self, string) :
return 100

DT_m.py
~~~
class DT (object) :
def __init__ (self, params) :
pass

def Date (self, epoch, pattern = 'd mmm ') :
dt = datetime.datetime.fromtimestamp (epoch)

Hook_m.py
~
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)

DB_m.py
~~~
from Hook_m import Hook

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


And a test script:

#!/usr/bin/python

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 "./3.py", line 20, in 
Obj.Connect ('Database')
  File "/mnt/isis/Projects/Python/Learning/DB_m.py", line 102, in Connect
self.TRACE ("DB::Connect (" + database + "," + mode)
  File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 314, in TRACE
self.DailyLog (msg)
  File "/mnt/isis/Projects/Python/Learning/Hook_m.py", line 98, in 
DailyLog
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!

Thanks,

Hook
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Inheritance confusion

2008-04-19 Thread Hook
Thanks to everyone who replied. Kay and Mark put me on the right track 
immediately. Ben is quite right - the fragment that I posted couldn't 
have given that error, but I didn't want to post the whole thing - 
perhaps wrongly, I thought it wouldn't help clarify what I thought the 
problem was. And that was the real issue - I had managed to convince 
myself that I had a naming problem in one of my own modules somewhere.

If anyone is interested in the background, I'm a long time Perl 
programmer trying to learn Python by converting a small set of standard, 
locally developed Perl libraries. It's an edifying experience, and I can 
understand why some colleagues like Python so much.

Again, thanks for the help, it's appreciated.

Hook
-- 
http://mail.python.org/mailman/listinfo/python-list