interactive window vs. script: inconsistent behavior

Larry Bates larry.bates at websafe.com
Fri Oct 7 00:15:52 CEST 2005


This also works and IMHO reads better:

d="5-18-05 to 5-31-05"
f,t=d.split(' to '))

Larry Bates

Bell, Kevin wrote:
> 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
> 
> 



More information about the Python-list mailing list