Where Things Live: Files, Folders, and Not Losing Your Work
Okay so here's the thing. You've written a program that says something back to you. Cool. But where did it actually go?
If you can't answer that question, you are going to lose work eventually. Not maybe. You will save something, close your editor, come back tomorrow, and stare at your screen wondering what happened to it. So let's fix that now, before it costs you anything real.
Your computer already has a filing system. Use it.
Every file you save lives somewhere specific. Not "in the computer" in some vague cloud sense, an actual folder, on an actual drive, with an actual path to get there. When you save a Python file and don't pay attention to where, it usually lands in whatever the default is, which is often some Documents or Downloads folder you never look at. Then you go hunting for it later and it's gone, except it's not gone, you just don't know where "there" is.
So the first move is boring and important: make yourself one folder for this whole class.
- Open your file explorer (Windows) or Finder (Mac).
- Go to Documents.
- Make a new folder called something like
python-class. Not spaces in the name if you can help it, computers get weird about spaces sometimes. Use a dash or underscore. - Inside that, make one folder per lesson if you want to get organized, or just dump everything in there to start. I did the messy version for probably my first two months of teaching myself this stuff and it was fine.
That's it. That's the whole trick. One home base, so you always know where to look.
Save early, save often, name things like you mean it
Here's a habit that'll save you real grief: save your file before you even finish writing the first line. Ctrl+S or Cmd+S, right away, give it a real name. lesson3_practice.py, not untitled1.py. Future you, three weeks from now, trying to remember what this file was for, will thank present you.
And save again constantly while you work. Every few minutes, out of habit, the same way you'd check your mirrors driving. Your editor is not automatically saving your work for you every time you type something, most of the free ones don't. That's on you.
Okay so here's the thing about backups
I have a story about this and it's not a fun one, but it's useful.
My very first script ever was supposed to rename photo files by date. I ran it on a folder of 400 photos, feeling like a genius. It renamed the first one fine. Then it tried to rename the second one to the exact same name as the first, which meant the first one got overwritten. Then the third did the same thing to the second. By the time it finished, I had one file left. Three hundred ninety nine photos, gone, because I hadn't backed anything up and I was testing a brand new script directly on real files that mattered.
I felt sick. I want you to feel a little sick right now too, just enough to build the habit, because it works.
So: before you run anything that renames, deletes, or moves files, especially your own real photos or documents, you copy that folder somewhere else first. An external drive, a different folder, cloud storage, whatever you've got. You test the risky thing on the copy. If it survives, great, now you trust it. If it doesn't, you just lost a copy, not the original.
This matters more once you start writing programs that touch actual files on your computer, which we'll do later in this class. For now, while you're just writing little practice scripts, the stakes are low. But the habit starts now, not later, because habits you build under low stakes are the ones that save you under high stakes.
A quick real-world example: tracking money and losing nothing
My wife Camille asked me once to write something that would track our grocery spending, mostly because a Costco run had gotten a little out of hand and she wanted receipts, literally. I wrote a small program that logged what we spent and by what category. It worked great. It just told us we spend an embarrassing amount on cheese, which, fine, we already suspected that.
Here's the part relevant to this lesson: I saved every version of that script as I built it, in its own folder, with dates in the filenames, grocery_v1.py, grocery_v2.py, and so on. Not because I'm some organizational wizard. Because I've been burned before, see above, and I've learned that a few extra seconds of naming things properly is nothing compared to rebuilding something from scratch because you overwrote the one version that worked.
My actual opinion on this
You do not need fancy backup software or a complicated system to avoid losing work. That's another one of those things people try to sell beginners that you flat out do not need yet. One organized folder and the discipline to save often and copy before you risk something. That's the whole system for now. It's not glamorous. It works.
Before next time
Go make your python-class folder if you haven't, and move whatever files you've already written into it. Takes two minutes and it'll save you a headache later, promise.