-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE]: Refactor Filesystem Operations to Use pathlib Instead of os.path #1301
Comments
Please explain the pros. How it improve the readability, consistency and how it makes the lib platform independent. |
@serengil Yes, of course.
Of course, these points are not crucial, and the code is effective as it stands. However, bringing file operations to a consistent style would improve the code even further. |
1- we are doing all file related things with So, PRs are more than welcome! |
Snippet1: import os
from pathlib import Path
root = "c:\\f1\\"
path = "f2/data.txt"
print(os.path.join(root, path)) # output: c:\f1\f2/data.txt can't be used in logs, shell scripts, etc.
print(Path(root) / Path(path)) # output: c:\f1\f2\data.txt correct Snippet2: # Now
import os
SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
ROOT_DIR = os.path.dirname(SRC_DIR)
# Suggested
from pathlib import Path
SRC_DIR = Path(__file__).resolve().parent.parent
ROOT_DIR = SRC_DIR.parent |
@kremnik as i mentioned, PRs are more than welcome |
Description
I would like to suggest refactoring the codebase to utilize the
pathlib
library for all filesystem operations instead ofos.path
. This change will provide improved readability, code consistency, and platform independence.If this proposal is approved, I could work on it.
Additional Info
No response
The text was updated successfully, but these errors were encountered: