I'm running Python 3.5 64-bit version on a Windows 7 machine.
I have a Python class whose constructor requires two arguments, self and an instance of another class:
class Level3_CoilsSet(Recordset):
def __init__(self, connection):
super().__init__(connection)
self.DefaultTableName = 'coils'
self._keyFields.append('coils_key')
self._defaultedFields.append('coils_key')
Here is the top of the Recordset
constructor (the only things left out are initialization of variables):
from adodb_pyodbc import Connection
from adodb_pyodbc import Field
class Recordset:
def __init__(self, connection: Connection = None):
self.Conn = connection
self.DefaultTableName = None
self.WhereClause = None
self.OrderClause = None
The Connection
class's constructor is nothing special:
class Connection:
def __init__(self):
self.pyConnection = None
self.AutoCommit = True
The Connection
and Recordset
classes reside in a folder in site-packages, along with an empty __init__.py
file.
When I run this, I get the following error:
C:\Python35\python.exe "C:/Customers/Nucor Crawfordsville/Scripts/64 bit/Testing/cpsa_simulator.py"
Traceback (most recent call last):
File "C:/Customers/Nucor Crawfordsville/Scripts/64 bit/Testing/cpsa_simulator.py", line 8, in <module>
from Level3_CoilsSet import Level3_CoilsSet
File "C:\Customers\Nucor Crawfordsville\Scripts\64 bit\Testing\Level3_CoilsSet.py", line 3, in <module>
class Level3_CoilsSet(Recordset):
TypeError: module.__init__() takes at most 2 arguments (3 given)
What is going on here? Why is an __init__()
method being called during import? What three arguments are given to it? The callback list given in PyCharm does not point to anything helpful. I had the same code working successfully in a different directory structure, with the three files in the adodb_pyodbc folder in the same folder as my main file, but now that I moved them into a folder under site-packages, it fails.