Python COM : Wierd Behaviour
hafeez at lancom.com.au
Thu May 18 06:52:27 CEST 2000
I have a python object for generating formatted Order documents which I
have exposed via
COM so that the API could be used by some order taking software written
in Delphi 4. The Python version in use is 1.5.2.
The code has been working fine for a couple of days and then yesterday
it kept on raising the following error. "Unexpected Python Error.
Exception TypeError: too many arguments; expected 1 got 2" on a method
in the object called "printToFile" (which writes out the document to a
specified file name. The actual method declaration is
The code has been working fine so far. So in an effort to debug it
further (I suspected that some mandatory fields in the document were
being left out which turns out not to be true) I implemented another
function "def rawPrint(self):" which returns a string representation of
objects field values. This function calls no other functions..it simply
returns a string representation of a list via str(self.document_values).
Surprisingly rawPrint fails with the same error as printToFile. I
changed rawPrint to do nothing ie.
and even to
The same error keeps on being raised "Unexpected Python Error. Exception
TypeError: too many arguments; expected 1 got 2". Even stranger .. the
printToFile method is now working, add an extra function rawPrint seems
to fix other problems!!!
I then changed rawPrint to
def rawPrint(self, value = 9):
and rawPrint calls stops raising the above exception and everything is
working withouth a hitch!!!
I have sample test code written in python and create tried creating the
COM object via win32com.client.Dispatch and
win32com.client.dynaminc.Dispatch but the python test code reports no
errors. Only test code that is written in delphi has this strange
Does anyone have an ideas,suggestions. The code seems to be
More information about the Python-list