Spent two days trying to get my Python script to read a simple text file
I kept getting a 'file not found' error even though I was sure the path was right. Turns out I was running the script from a different folder than I thought, so the path was wrong. How do you guys keep track of where your files are when you're just starting out?
Always use absolute paths when you're testing, it saves so much headache. I make a habit of printing out the current working directory at the start of my scripts with os.getcwd(). That way you can see exactly where Python thinks it is.
Oh absolutely, I learned that the hard way too. I spent half a day once trying to figure out why my script couldn't find a config file, and it was just because I was running it from a different folder than I thought. Printing the cwd right away is such a simple fix.