-1

I am trying to write a code for a path to a directory that does not include a drive name. I don't want anything that starts with 'C:/'. We have a directory name we will say 'Spiers' with files in it. Basically I am splitting a file name and working that into a file path in a directory. Its very confusing I know but my boss is trying to teach me new ways for learning python.

Spiers12
  • 17
  • 1
  • 1
    Could you please give a replicable code sample? Have you possible looked into the `glob` package? – sami-amer May 10 '22 at 17:52
  • 1
    `glob` is the way to go here. Recommend checking that out. – Thornily May 10 '22 at 17:53
  • Possible duplicate of [Difference between `./` and `~/`](https://stackoverflow.com/a/55342466/874188) – tripleee May 10 '22 at 17:56
  • In other words you don't want to use an absolute path. On Windows an absolute path begins with a drive letter. On Unix type systems an absolute path starts with a forward slash (the root directory). So you'll be needing to work with relative paths. That can be highly problematic because you would need to know where the directory that you're really interested in is on the file system "relative" to your current working directory. Think about this challenge on a Windows system that has multiple drives. The headache potential is enormous – Albert Winestein May 10 '22 at 18:00

0 Answers0