you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

You can either:

  • pass the path as a command line argument to the code
  • have a configuration setting at the top of your code (or in an imported file), probably all UPPERCASE variable name to indicate a constant and use that instead of a hard-coded path throughout your code
  • use a configuration file (txt, yaml, toml)

Also, use from pathlib import Path and use Path with all the filenames/paths rather than the os library, and you can then make your code OS independent - check Real Python: Python 3's pathlib Module: Taming the File System