[python-win32] TypeError: PyTime cannot be compared to other types

Randy Syring randy at rcs-comp.com
Fri Mar 13 16:39:29 CET 2009


I have a Python script that interacts with Excel files through COM.  In 
one section of the code, I do a loop that compares values:

    def find_row(self, sheet, needle, column, start=1, end=100):
            for x in range(start, end+1):
                if sheet.Range('%s%s' % (column, x)).Value == needle:
                    return x
            raise ValueNotFound

In build 212, this worked fine.  However, with build 213, I am now 
getting the exception:

    ", line 170, in find_row
        if sheet.Range('%s%s' % (column, x)).Value == needle:
    TypeError: PyTime cannot be compared to other types

I read the release notes for build 213, but did not find anything 
specifically mentioning changes related to PyTime.

So, is this a bug or a just part of the upgrades in build 213?  If its 
not a bug, what would be the proper way to implement find_row() taking 
into consideration that some values will be PyTime objects that can not 
be directly compared to other types.  I guess I could just catch the 
exception and do something with it.  But I am not sure how to work with 
PyTime objects.

Thanks.

-- 
--------------------------------------
Randy Syring
RCS Computers & Web Solutions
502-644-4776
http://www.rcs-comp.com

"Whether, then, you eat or drink or 
whatever you do, do all to the glory
of God." 1 Cor 10:31

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20090313/305895f6/attachment.htm>


More information about the python-win32 mailing list