Python newbie question re Strings and integers

Miki miki.tebeka at gmail.com
Fri Sep 19 01:35:48 CEST 2008


>     currentSymbol=filename[int(filenameStart),int(extensionStart)]
Should be
    currentSymbol=filename[int(filenameStart):int(extensionStart)]
(change , to :)

You don't need to convert to int all the time, rfind will return an
integer.

Also you can use os.path for this

    from os.path import basename, splitext
    currentSymbol = splitext(basename(filename))[0]

HTH,
--
Miki <miki.tebeka at gmail.com>
http://pythonwise.blogspot.com



More information about the Python-list mailing list