the mystery of dirname()
anand.shashwat at gmail.com
Sat Feb 20 19:34:14 CET 2010
got it. thanks. :)
On Sat, Feb 20, 2010 at 11:19 PM, MRAB <python at mrabarnett.plus.com> wrote:
> Shashwat Anand wrote:
>> basically I infer that : dirname = path - basename, like for path =
>> '//x', basename = x, hence dirname = '//'
> Basically, os.path.dirname() should return the directory name, which
> means dropping everything after the last slash, and also the last slash.
> However, there's the special case where the name is in the root
> directory, and you want to retain the slash(es).
> When building a path (os.path.join()) you want to join the parts with a
> single slash between them, but there's the special case when a part is
> the root directory, and you don't want to add a slash between them, eg
> os.part.join('/x', 'y') should return '/x/y', but os.part.join('/', 'x')
> should return '/x'.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list