Coder Social home page Coder Social logo

Comments (6)

zware avatar zware commented on June 29, 2024 4

As already explained, there's no bug in the docs or implementation here. However, we might be able to clarify the docs a bit: I think the confusion here came from the fact that the broken symlink case is called out explicitly in a separate sentence:

Return ``True`` if *path* refers to an existing path. Returns ``True`` for
broken symbolic links. Equivalent to :func:`exists` on platforms lacking

This reads a bit clearer to me:

Return True if path refers to an existing path, including broken symbolic links.

from cpython.

eryksun avatar eryksun commented on June 29, 2024 1

os.path.lexists() doesn't follow symlinks, so it returns True for a broken symlink. Use os.path.exists() if you need False for a broken symlink.

from cpython.

pfortin avatar pfortin commented on June 29, 2024

But what is the purpose of a function that only returns True?

from cpython.

eryksun avatar eryksun commented on June 29, 2024

os.path.lexists() returns True only if path exists, regardless of the file type. It's useful when one needs to know whether anything with the given name exists, regardless of whether it's a regular file, directory, symlink, named pipe/socket, or device.

from cpython.

terryjreedy avatar terryjreedy commented on June 29, 2024

If the doc matches the behavior, there is no bug. If the behavior is intended, and useful, we are unlikely to change it. Feature changes usually need be be discussed on discuss/ideas.

from cpython.

erlend-aasland avatar erlend-aasland commented on June 29, 2024

Resolved by:

from cpython.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.