How do I take a directory name from a given dir?
michael at elehack.net
Mon May 1 21:57:48 CEST 2006
On Mon, May 01, 2006 at 12:42:58PM -0700, Merrigan wrote:
> The issue I am currently having isto "extract" the directory name from
> a given directory string. For example: from the string
> "/home/testuser/projects/" I need to extract the "projects" part. The
> problem is that the directory names that needs to be used will never be
> the same lenght, so as far as my (very limited) knowledge stretches,
> slicing and indicing is out of the question.
Look at the os.path module, especially the basename and dirname
functions. basename will extract the "base name", that is, the last
component of a path.
mouse, n: a device for pointing at the xterm in which you want to type.
Visit me on the Web: http://www.elehack.net
More information about the Python-list