Re: the mystery of dirname()

2010-02-20 Thread Shashwat Anand
got it. thanks. :) On Sat, Feb 20, 2010 at 11:19 PM, MRAB wrote: > Shashwat Anand wrote: > >> basically I infer that : dirname = path - basename, like for path = >> '//x', basename = x, hence dirname = '//' >> >> [snip] > Basically, os.path.dirname() should return the directory name, which >

Re: the mystery of dirname()

2010-02-20 Thread MRAB
Shashwat Anand wrote: basically I infer that : dirname = path - basename, like for path = '//x', basename = x, hence dirname = '//' [snip] Basically, os.path.dirname() should return the directory name, which means dropping everything after the last slash, and also the last slash. However, the

Re: the mystery of dirname()

2010-02-19 Thread Shashwat Anand
basically I infer that : dirname = path - basename, like for path = '//x', basename = x, hence dirname = '//' On Sat, Feb 20, 2010 at 8:47 AM, MRAB wrote: > Shashwat Anand wrote: > >> But this is posixpath, right ? So '//x' like path will not occur as far as >> I guess ? >> >> Can you guarante

Re: the mystery of dirname()

2010-02-19 Thread MRAB
Shashwat Anand wrote: But this is posixpath, right ? So '//x' like path will not occur as far as I guess ? Can you guarantee that? It's safer to just leave it as it is, just in case! :-) On Sat, Feb 20, 2010 at 8:35 AM, MRAB > wrote: Shashwat Anand wro

Re: the mystery of dirname()

2010-02-19 Thread Shashwat Anand
But this is posixpath, right ? So '//x' like path will not occur as far as I guess ? On Sat, Feb 20, 2010 at 8:35 AM, MRAB wrote: > Shashwat Anand wrote: > >> In the following code sample : >> >> def dirname(p): >> >>"""Returns the directory component of a pathname""" >>i = p.rfind('/')

Re: the mystery of dirname()

2010-02-19 Thread MRAB
Shashwat Anand wrote: In the following code sample : def dirname(p): """Returns the directory component of a pathname""" i = p.rfind('/') + 1 head = p[:i] if head and head != '/'*len(head): head = head.rstrip('/') return head def dirname1(p): i = p.rfind('/')

the mystery of dirname()

2010-02-19 Thread Shashwat Anand
In the following code sample : def dirname(p): """Returns the directory component of a pathname""" i = p.rfind('/') + 1 head = p[:i] if head and head != '/'*len(head): head = head.rstrip('/') return head def dirname1(p): i = p.rfind('/') + 1 head = p[:i]