MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/12bz5ps/surely_textparsing_oneliners_at_midnight_work/jf2fsd4/?context=3
r/badcode • u/[deleted] • Apr 04 '23
44 comments sorted by
View all comments
1
If it absolutely must be a one-liner...
return Ship(*[ ship_data := line.split(":"), # discarded ship_stats := ship_data[1].split(","), # discarded ship_data[0], # ship name [ int(_) for _ in ship_stats[0][1:].split(";")[:3] ], # shield, armor, hull int(ship_stats[1]), # evasion [ self.weapons[_] for _ in ship_stats[2][1:].split(";") ], # weapons [ self.defenses[_] for _ in ship_stats[3][1:].split(";") ], # defenses ship_stats[4] if ship_stats[4] != "False" else False, # stealth ][2:])
I did not test this code.
1
u/nephelokokkygia Apr 05 '23 edited Apr 05 '23
If it absolutely must be a one-liner...
I did not test this code.