Retrieving Filename from Path

Rob Cowie cowie.rob at gmail.com
Wed Aug 31 13:12:07 EDT 2005


Hi,

Given a string representing the path to a file, what is the best way to
get at the filename? Does the OS module provide a function to parse the
path? or is it acceptable to split the string using '/' as delimiters
and get the last 'word'. The reason I'm not entirely happy with that
method is that it is platform specific. I would prefer to use a built
in method if possible.

Cheers,

Rob Cowie




More information about the Python-list mailing list