interactive window vs. script: inconsistent behavior

Bell, Kevin kevin.bell at slcgov.com
Thu Oct 6 16:51:45 EDT 2005


Oops!  Sorry about that post.  I'm pulling data from excel, and needed
to convert the object I pulled into a string before slicing.

I guess I should look (more thoroughly) before I leap.




-----Original Message-----
From: python-list-bounces+kevin.bell=slcgov.com at python.org
[mailto:python-list-bounces+kevin.bell=slcgov.com at python.org] On Behalf
Of Bell, Kevin
Sent: Thursday, October 06, 2005 2:44 PM
To: python-list at python.org
Subject: interactive window vs. script: inconsistent behavior

The following works in the interactive window of PythonWin, but fails in
a script.  TypeError: Objects of type 'slice' can not be converted to a
COM VARIANT

I just need to parse out these dates, but it's making me crazy.
Shouldn't it work in both the interactive window and a script?  


>>> d = "5-18-05 to 5-31-05"
>>> print d[0:d.find("to")-1]
5-18-05
>>> print d[d.find("to")+3:]
5-31-05
>>>




Kev


-- 
http://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list