-
Notifications
You must be signed in to change notification settings - Fork 107
Clean up the names and initializations of path variables #115
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
Conversation
No functional change, since the actual paths remain the same.
|
For passing around groups of related variables (e.g. paths): a dataclass. |
|
Okay, I think this is at nice as it gets. I used a frozen dataclass, so that paths cannot be modified accidentally during execution. And I shortened most identifiers, compared to my initial proposal ( BTW, |
|
Since I merged the newest commits from |
|
FYI, I'll be offline the next ~ 8 to 10 hours... |
|
OK, nice work on this. Thanks! |
I've noticed that there's a dozen of path variables at the start of main which do not follow a common naming pattern, and the way that their initializations reference each other makes it difficult to understand what is where:
They end in five different postfixes, but they all represent a path (or path template), either pointing to a regular file or a directory:
_folder_folder_name_path_filename_filename_templateWhen I implement #99, I need to work a lot with those paths, and because the initialization code needs to access the old paths to move things over to the new paths, I'll have to add even more of those variables. It's hard to find matching names for them right now.
So what do you think of a common naming pattern like this? I'll replicate the important part of my change here, since it's kinda buried at the bottom of the diff. This change does not affect how the program works, everything should still be in the same place. (So this does not solve #99, not even partially, it's just preparation for a cleaner implementation of #99.)
I'm not always a fan of identifier prefixes like
dir_path_but I think it makes it much easier to see what's the same and what's different between adjacent lines.The comments like
# used to be log_pathare there to help others resolve merge problems. Later, we won't need the old names for anything and could delete the comments.Also, I think these path variables are conceptually immutable and globally valid, so I'm not very happy with the long argument lists in function calls just to pass them around. I'd really like to make them globally accessible, but I'm not sure what's the best way to do that in python. True global variables? Put them in a dict and make that dict global? Or pass that dict around, instead of several individual vars? Singleton?!
Depending on that, I might also change the variable names to screaming snake case, i.e.
FILE_PATH_ACCOUNT_JSinstead offile_path_account_js.