Javascript to Python

Sam Collett sam_collett at lycos.co.uk
Fri Mar 1 12:12:40 EST 2002


Does anyone know of any good sites on Javascript > Python examples?
I have a function in javascript that returns the file extension:

function FileExtension(sFilePath)
{
    return Right(sFilePath,sFilePath.length-sFilePath.lastIndexOf("."))
}

so FileExtension("/path/to/file.doc") would return .doc
I would also want to return the filename (file) and the path
(/path/to/). How would I go about that?

What equivalents to the functions Right and Left (right side of
string, left side of string)

Also is there an easier way to do number incrementing (just me being
lazy):
while r<5
 print r
 r=r+1

I have tried r++ to add 1 each time, and r-- to take away one, but
this does not work, so is the only way r=r+1 or r=r-1 ?

TIA



More information about the Python-list mailing list