About 50 results
Open links in new tab
  1. pathlib.Path vs. os.path.join in Python - Stack Overflow

    Apr 15, 2021 · pathlib is the more modern way since Python 3.4. The documentation for pathlib says that "For low-level path manipulation on strings, you can also use the os.path module."

  2. python - How do I append a string to a Path? - Stack Overflow

    Jan 10, 2018 · I mostly use the path module in os so the usage is a bit different. Path creates a path object but in os.path the returned object is a string so it couldn't call that function on itself.

  3. python - How to use glob () to find files recursively? - Stack Overflow

    For Python older than 2.2 there is os.path.walk() which is a little more fiddly to use than os.walk()

  4. python - How to get absolute path of a pathlib.Path object? - Stack ...

    Feb 28, 2017 · p = pathlib.Path('file.txt') The p object will point to some file in the filesystem, since I can do for example p.read_text(). How can I get the absolute path of the p object in a string? Appears …

  5. python - How do I get the full path of the current file's directory ...

    2813 The special variable __file__ contains the path to the current file. From that we can get the directory using either pathlib or the os.path module. Python 3 For the directory of the script being run:

  6. How do I check if a directory exists in Python? - Stack Overflow

    133 Python 3.4 introduced the pathlib module into the standard library, which provides an object oriented approach to handle filesystem paths. The is_dir() and exists() methods of a Path object can be used …

  7. How do I get the filename without the extension from a path in Python?

    Using pathlib.Path.stem is the right way to go, but here is an ugly solution that is way more efficient than the pathlib based approach. You have a filepath whose fields are separated by a forward slash /, …

  8. pathlib.Path ().glob () and multiple file extension

    Dec 5, 2017 · A bit late to the party with a couple of single-line suggestions that don't require writing a custom function nor the use of a loop and work on Linux: pathlib.Path.glob () takes interleaved …

  9. How to get only the name of the path with python? [duplicate]

    Jun 15, 2018 · In Python 3.4 or newer (or as a separate backport install), you can also use the pathlib library, which offers a more object-oriented approach to path handling. pathlib.Path() objects have a …

  10. Why does pathlib have both PurePath & Path? - Stack Overflow

    Aug 5, 2019 · 42 More than an answer to the question, I am trying to learn how to make sense of the Official Python Documentation. I understand that Path inherits from PurePath, but I am unable to …