[docs] os.path.basename() bug

Frank Cusack fr4nk at mode.net
Fri Sep 21 12:50:58 EDT 2018


My mistake! I misread split() as referring to string.split(), as opposed to
os.path.split(). It did seem inconceivable that such an error could have
been there for so long.

Thank you for the response.

On Fri, Sep 21, 2018 at 9:26 AM, Zachary Ware <zachary.ware+pydocs at gmail.com
> wrote:

> Hi Frank,
>
> On Fri, Sep 21, 2018 at 8:44 AM Frank Cusack <fr4nk at mode.net> wrote:
> > os.path.basename(path)¶
> >
> > Return the base name of pathname path. This is the second element of the
> pair returned by passing path to the function split(). Note that the result
> of this function is different from the Unix basename program; where
> basename for '/foo/bar/' returns 'bar', the basename()function returns an
> empty string ('').
> >
> > Clearly 'second element' is wrong, even for the given example.
>
> Can you demonstrate how it is wrong?  From my own testing everything
> looks correct:
>
>    bash-3.2$ basename foo/bar/
>    bar
>    bash-3.2$ python3
>    Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24)
>    [Clang 6.0 (clang-600.0.57)] on darwin
>    Type "help", "copyright", "credits" or "license" for more information.
>    >>> import os
>    >>> os.path.basename('foo/bar/')
>    ''
>    >>> os.path.split('foo/bar/')
>    ('foo/bar', '')
>
> --
> Zach
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/docs/attachments/20180921/5b67d68a/attachment-0001.html>


More information about the docs mailing list