question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pathlib, Pathlib everywhere.

See original GitHub issue

There are many places where we could make use of Pathlib.

Look for any places that uses with open(...) and ask yourself:

  • is the argument a string ?
  • would it make sens to make it a Path(),
  • how far upstream in the code can I make it a Path.

Don’t try to bite more than you can chew (or more than I can review), try to fix 1 place at a time.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:11
  • Comments:22 (12 by maintainers)

github_iconTop GitHub Comments

4reactions
Carreaucommented, Oct 23, 2020

Hi everyone, I’m trying to review all the PRs, there are many tacking this issues, be careful some of you are sending changes for which there are already other PRs opened.

3reactions
MrMinocommented, Oct 11, 2020

Might also be of use: https://docs.python.org/3/library/pathlib.html#correspondence-to-tools-in-the-os-module

There are many places other than with open() that might use pathlib treatment:

-    conda_history = os.path.join(sys.prefix, 'conda-meta', 'history')
-    return os.path.exists(conda_history)
+    return Path(sys.prefix, 'conda-meta', 'history').exists()
Read more comments on GitHub >

github_iconTop Results From Across the Web

pathlib — Object-oriented filesystem paths — Python 3.11.1 ...
Source code: Lib/pathlib.py This module offers classes representing filesystem paths with ... A path object can be used anywhere an object implementing os....
Read more >
Using pathlib.Path, how to efficiently check if a directory ...
Using pathlib.Path, how to efficiently check if a directory resides anywhere under another directory? · How are you measuring "better"? – Scott ...
Read more >
Why you should be using pathlib - Trey Hunner
Since Python 3.6, pathlib.Path objects work nearly everywhere you're already using path strings. So I see no reason not to use pathlib if...
Read more >
Why Python Pathlib Excels at Handling Files - Built In
The Python pathlib module provides an easier method to interact with the filesystem no matter what the operating system is. It allows a...
Read more >
Pathlib | Dev Cheatsheets - Michael Currin
This is useful when running the script from anywhere in or outside the repo and keeping paths relative to that app directory i.e....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found