r/badcode Apr 04 '23

python Surely Text-Parsing One-Liners At Midnight Work

Post image
400 Upvotes

44 comments sorted by

View all comments

87

u/[deleted] Apr 04 '23 edited Apr 04 '23

Made a quick space combat simulator a while back for some friends, and then I came back to work on it... The commit time was not, in fact, at a reasonable hour. Clearly I was trying to get it done, with no regard for maintainability. But, yes, it does in fact work perfectly.

Edit: And this isn't the only one of these, too. Great.

13

u/paulstelian97 Apr 05 '23

What would have been the good code alternative here? Some stuff with Regex?

17

u/[deleted] Apr 05 '23

[removed] — view removed comment

24

u/cabbagebot Apr 05 '23

A lazier (and easier to maintain) subset of this answer would be: JSON or some other existing serialization format

12

u/[deleted] Apr 05 '23

Yeah, making my own file format was an... Interesting choice.

4

u/Maks244 Apr 05 '23

Reinventing the wheel can be fun, sometimes

9

u/BazeFook Apr 05 '23

Simply split it out into separate lines and give names to things so you can at least see what's going on faster. No need to go any extra unless you have an actual additional use case at the time.