Sean 'Shaleh' Perry
shalehperry at attbi.com
Fri Mar 1 18:26:44 CET 2002
On 01-Mar-2002 Sam Collett wrote:
> 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?
import os, os.path
>>> filename = '/path/to/foo.doc'
os.path has a bunch of nice path related tools like abspath() and join().
Check out the python docs.
> What equivalents to the functions Right and Left (right side of
> string, left side of string)
sorry, not quite sure what the Right side of a string is (-:
> Also is there an easier way to do number incrementing (just me being
> while r<5
> print r
> 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 ?
in python 1.5.2 and earlier the only way was r = r + 1. In the 2.x series the
like languages) r += 1. There is equivalents for the other standard math ops.
More information about the Python-list