Python newbie question re Strings and integers

rmac rmacneill at
Fri Sep 19 01:10:02 CEST 2008

the following code attempts to extract a symbol name from a string:
    extensionStart = int(filename.rfind('.'))
    filenameStart = int(filename.rfind('/'))
    #print 'Extension Start - ' + str(extensionStart)
    #print 'FileName Start - ' + str(filenameStart)

Uncommenting the print statements clearly show the values to be
integers (and without the str casts actually provide int+string

However, executing this code results in...
    opening - /Users/rmac/Documents/Sandbox/data/MarketData/AA.csv
    Traceback (most recent call last):
      File "", line 25, in <module>
    TypeError: string indices must be integers

Running Python 2.5.2_5 on OSX

More information about the Python-list mailing list