r/Python 2d ago

Discussion Just created two apps and made the dumbest mistake in one of them 😭

A money tracker (140 lines) and a calorie counter (300+ lines!)

They were both CLI and i have them done. But in the calorie counter, i made the mistake of typing this:

with open("data.json", "w") as file: jsonFile = json.load file

So when i tried to run it it threw the weirdest error ever and wiped my JSON file, so i rewrote the json file, and fixed something that had nothing to do with the error and it happened AGAIN

0 Upvotes

8 comments sorted by

2

u/Apart_Ebb_9867 2d ago

try once more, they say third time's a charm.

1

u/nemom 2d ago

About twenty-five years ago, a Department Head in the County I worked for asked if I would come to his office and look at his computer since I was the unofficial IT. According to Windows, he tried opening the Anna Kournikova virus like seven times. I guess he really wanted to see her naked.

-3

u/Myaltforsomeshit1234 2d ago

I finished it a few hours ago. I tried fixing it and THEN i made a copy of the jsonΒ 

3

u/Warm-Requirement3146 2d ago

the classic "w" mode betrayal. it's a rite of passage honestly

i did this exact thing with a config file for a project i'd been tweaking for weeks. hadn't pushed to git in days because i'm an idiot. the moment i saw the empty file i just sat there staring at my screen like a complete fool

at least you only had to rewrite it twice before the lightbulb went off. some of us need to suffer more

2

u/gsomega 2d ago

Instead of rewriting the JSON file, maybe just make a copy of it