Newbie Question regarding __init__()

MRAB python at mrabarnett.plus.com
Fri Jul 31 14:33:57 EDT 2009


Simon wrote:
> Hi
> 
> I want to create an instance of dcCursor which inherits from
> dcObject.  When I run the following code it gives the error shown.
> Can some explain to me what is wrong? I have included the dcObject.py
> and dcCursor.py below.
> 
>>>> import dcObject
>>>> import dcCursor
>>>> x = dcCursor.dcCursor()
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in <module>
> TypeError: __init__() takes no arguments (1 given)
> 
All instance methods must have the instance as the first argument, by
convention called 'self':

> # -*- coding: utf-8 -*-
> # dcCursor.py - The base Cursor Class
> 
> from dcObject import dcObject
> 
> class dcCursor(dcObject):
>     """The base Cursor Class"""
>     def OpenCursor(tcTemp,tcTable):
     def OpenCursor(self, tcTemp, tcTable):

>         """Opens the specified cursor
>         Parameters: tcTemp,tcTable"""
>         pass
> 
>     def CreateCursor(tcTable):
     def CreateCursor(self, tcTable):
...

and so on, including the '__init__' method.



More information about the Python-list mailing list