How to extract the file names???

Alex Martelli aleaxit at yahoo.com
Fri Apr 20 12:56:04 EDT 2001


"EdwardT" <edwardt at trillium.com> wrote in message
news:9bnom3$g9a at news.or.intel.com...
> Hi currently I have the following code that asks the user for input file
> names, but it returns the filesname with the full path attaching to it.
ButI
> just want the filenames without the fullpath how can i do it??
    [snip]
> /vobs/qa/stf/ctf/src/sample/tpu/log/tpTcCTFTEST7/tp_acc.1
>
> But I just want tp_acc.1  . what should I do??

"import os.path", then os.path.basename(thefullpath) returns
the part after the last slash (on Unix -- the appropriate
separator, on whatever platform).


Alex







More information about the Python-list mailing list