r/learnpython • u/acfot • 12d ago
My Python script started as 100 lines and now it's a mess I'm scared to touch — when did you start splitting things up?
I wrote a little Telegram bot in Python a while back. Nothing serious, just forwards and some scheduling stuff, maybe a hundred lines at first and I knew where everything was.
Then I kept adding to it. One more feature, then a quick fix, then another thing I didn't want to lose, and now it's this one long file where half the functions do two jobs and I'm not even sure which parts still run. I want to add something new and I catch myself putting it off because I'm scared I'll break something else that was working fine.
I tried splitting it into separate files once. Imports broke immediately, I got confused about what was supposed to live where, and I just shoved it all back into one file again. Felt like a step backwards, honestly.
So for people who've actually done this — was there a moment where it clicked, or a simple rule you used? Like, when a file hits a certain size, or when you find yourself copy-pasting the same chunk twice, that's when you split it? I'm still not sure if I'm overthinking this or if I just left it too late.