Problem subclassing Database class

Alex Martelli aleaxit at yahoo.com
Tue Aug 29 16:12:56 EDT 2000


<christhemule at my-deja.com> wrote in message
news:8oh003$ssa$1 at nnrp1.deja.com...
> I'm trying to subclass the DB class in the PyGreSQL module with the
> following code fragment:
>
> class Database(DB):
>     "Class providing a wrapper around the DB class in PyGreSQL"
>
>     def __init__(self, *args, **kw):
>         DB.__init__(self, args, kw)
    [snip]
> I'm new to Python, and cannot see what I'm doing wrong.

You're calling DB.__init__ with exactly 3 arguments (the first an
instance reference, the second a tuple, the third a dictionary),
not with the same arguments with which your __init__ was
actually called.

To accomplish the latter, which is what you need here, in Python 1.5.2:

        apply(DB.__init__, (self,)+args, kw)

or, in Python 1.6 or later, the simpler form:

        DB.__init__(self, *args, **kw)


Alex






More information about the Python-list mailing list