Inheritance confusion

7stud bbxx789_05ss at yahoo.com
Sat Apr 19 03:00:05 EDT 2008


On Apr 19, 12:37 am, Hook <H... at somewhere.nowhere.co.au.it> wrote:
> 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 yyyy') :
>         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 <module>
>     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


import time

time()

--output:--
Traceback (most recent call last):
  File "test1.py", line 3, in ?
    time()
TypeError: 'module' object is not callable


Did you do that somewhere?



More information about the Python-list mailing list